This is a small alias that splits the message up into several lines if it exceeds the maximum the server can take.
If your server can take more than 452 just change that number
Would like improvements if possible, and by that i dont mean "Oh look i can pipe the script to make it look smaller"
This is generally for use with bots.
;;Created by [Plornt] to solve the issue of too long messages, basic version doesnt carry over formatting to the other lines but im sure you could add that easilly
alias msg {
if ($len($2-) > 452) {
var %channel $1, %x 1, %msgnum 1
tokenize 32 $2-
while (%x <= $0) {
if ($len($($+($,%msgnum,-,%x),2)) > 452) {
msg %channel $($+($,%msgnum,-,$calc(%x - 1)),2)
var %msgnum %x
}
inc %x
}
}
else msg $1-
}
Atr,> @sunslayer, 'twas a joke between Plornt & I. ;)Between is a preposition. In English, a preposition must be followed by an indirect object pronoun. Me is an indirect object pronoun, and I is a subject pronoun. Therefore, between has to be followed by me, not I.
I can't help but point out the difference. :P
It cuts off because you have the outer if -- else conditions and then inside the while loop you have an if with no else so the remainder of that drops through the last "> 452 if" is lost without being sent to the channel.
You should be able to fix it by removing the outer if else and just letting the script message the remaining text when it drops out of the while loop.
alias msg {
var %channel $1, %x 1, %msgnum 1
tokenize 32 $2-
while (%x <= $0) {
if ($len($($+($,%msgnum,-,%x),2)) > 452) {
msg %channel $($+($,%msgnum,-,$calc(%x - 1)),2)
var %msgnum %x
}
inc %x
}
msg %channel $($+($,%msgnum,-,$calc(%x - 1)),2)
}
instead of piping several "vars" just use ","
var %a = 1, %b = 2, %c = 3
and even then i dont think the "="'s are needed.
why 452? i think different servers use different limits.
an alias/identifier, would be nice
example:
alias msg.limit return 452
then in script, you can do $msg.limit
and people can edit that alias/identifier as they wish.
oh also, in your description, you should add that the usage is
$chan
and i may be wrong but there is no need to tokensize, since your outgoing msg is already tokened by spaces.
heres a version of this i wrote a while ago
alias check.len {
var %aa = $1-
if ($len(%aa) <= 250) { msg $chan %aa }
else {
var %a = 250, %b = $len(%aa)
while (%a <= %b) {
msg $chan $iif(%a == 250,$left(%aa,%a),$right($left(%aa,%a),$calc(%a - 250)))
if (%a < %b && $calc(250 + %a) > %b) { msg $chan $right(%aa,$calc(%b - %a)) | halt }
else { inc %a 250 }
}
}
}
Oh look I can pipe the script to make it look smaller:
alias msg {
if ($len($2-) > 466) { var %channel $1 | tokenize 32 $2- | var %tot $0 | var %x 1 | var %msgnum 1 | while (%x <= %tot) { if ($len($($+($,%msgnum,-,%x),2)) > 466) { msg %channel $($+($,%msgnum,-,$calc(%x - 1)),2) | var %msgnum %x } | inc %x } } | else msg $1- }
Sorry, couldn't resist. Anywho, nice work Plornt.