msg/notice control alias

By FordLawnmower on Jul 07, 2009

This is a little snippet but it is extremely useful. This alias will allow you to send large amounts of text to a channel without worrying about flooding or the size of the line. If you send it a line that is 4000 characters the alias will break it down into 10 or so lines and send them to their destination with a 1 1/2 second delay. If the delay is not enough just change this line

inc %Dtimer 1.5

1.5 works for me but it might not for everyone.
I repeatedly threw 12 thousand characters per 3 seconds, at this alias and I couldn't break it. All of the lines came out in perfect order.

*** One thing to note ****
This was designed for normal text! With spaces in between the words :)
$str(c,431) will break this code. The splitting of the text is based on the closest space to 430 characters without going over. I did it this way to prevent the splitting of words.

Syntax
/Put msg #channel text to send
/Put notice nickname text to send
You can also use .notice and .msg with this :)

Post any problems or suggestions here.
Rewrites or different versions of this are welcome.
It would be interesting to see how someone else would try to accomplish this.
I saw a script for this once on mircscripts, but it was several pages long.

alias Put {
  if (!$regex($1,/(\.|^)(msg|notice)$/Si)) || (!$3) { echo -st **Put error** Syntax /Put msg #channel text - or - /Put notice nickname text  | return }
  tokenize 32 $regsubex($1-,/([$\|%\[\]\}\{][^\s]*)/g,$+($chr(2),$chr(2),\t))
  var %tokens $0, %Tstart 3, %Dtimer 1500
  if ($timer($+(Put,$2,$network)).secs) { %Dtimer = $calc($v1 * 1000) }  
  while ($len($($+($,%Tstart,-,%tokens),2)) > 430) {
    dec %tokens
    if ($len($($+($,%Tstart,-,%tokens),2)) <= 430) {
      .timer -m 1 %Dtimer $1-2 $($+($,%Tstart,-,%tokens),2))
      inc %Dtimer 1500
      %Tstart = $calc(%tokens + 1)
      %tokens = $0
    }
  }
  .timer -m 1 %Dtimer $1-2 $($+($,%Tstart,-,%tokens),2))
  .timer $+ $+(Put,$2,$network) -m 1 $calc(%Dtimer + 1500) noop 
}

Comments

Sign in to comment.
WorldDMT   -  Jul 09, 2009

ok i did confuse whith hinc sorry the hinc dont take decimal befor version 6.3

about variable from version 6.32 and up the variable limit 4140 chr.

 Respond  
FordLawnmower   -  Jul 09, 2009

@WorldDMT I don't know what version of mirc that decimals were added to inc, but I know that it's not 6.3. I do most of my testing on 6.16 and it allows decimals.
I just typed this

//var %tester 1 | inc %tester 1.5 | echo -a %tester

The output is 2.5 on mIRC version 6.16.
If you are speaking of the timer decimal, I think it is new to 6.3. In this case, if inc %var 1 doesn't work you will have to change it to inc %var 2. There is no need to change this really, because if you have a version of mirc prior to 6.32, your variable limit is only 960. I don't think 3 lines in 3 seconds will cause a flood.
The decimal will only be needed to add delay for larger variables sent by newer versions of mIRC.

As for not using $calc with a single calculation, I think this is a mood point.
I think that %var = $calc(1 + 1) does the exact same thing as %var = 1 + 1 .
The former doesn't invoke $calc a second time. If I am wrong, post a link to show this or give a working example.

I choose to use $calc for all calculations just as I always use {} after if and while statements. It's a personal preference and for me it makes the code easier to follow.

 Respond  
WorldDMT   -  Jul 09, 2009

hi

for 1.5 i think it's from version 6.3 that mirc allows it
otherwise it will be considered 1

and mabe %Tstart = $calc(%tokens + 1) dont need $calc try %Tstart = %tokens + 1

 Respond  
Automotive   -  Jul 08, 2009

I like how you break the server rules with this code..:P

 Respond  
FordLawnmower   -  Jul 07, 2009

I use this for scripts where the message that I am sending is sometimes of unknown length. For instance, a script that gets a horoscope from a website. Many times it will fit in a single message but on occasion it will be longer and get cut off.

Using an alias like this will add a more lines if the message is longer :)

 Respond  
blitzz   -  Jul 07, 2009

Oic..Now i understand..I never send message or notice that long, but looks like this is usefull someday..

 Respond  
FordLawnmower   -  Jul 07, 2009

No it's not set by the server blitzz. If you try to send a message or notice to a channel or nickname that is 4 thousand characters long, the server will cut it off at it's limit and the rest of the message will be lost. The limit is usually between 430 and 435 characters. This script will break the line down into smaller messages that the server can handle and it will send them 1.5 seconds apart. Servers won't do this for you.

The -st is there for a reason. This code is made to be used in a script. Script errors should be posted in status.

 Respond  
blitzz   -  Jul 07, 2009

I think this code function already set by the server.

And echo -at or -a maybe, so the syntax error appear on where the person active.

(Sorry, bad english. Cant speak well) :)

But this works fine.

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.