!go and !leave for bot

By Vegito on Oct 13, 2013

Example:
!go #chan #chan #chan makes the bot join the specified channels.
!leave #chan #chan #chan makes the bot leave the specified channels.

on $*:TEXT:/^!(go|leave) /Si:#: {
  if ($nick != BotOwnerNickHere) halt
  if (!$2) { notice $nick 12Syntax: $1 $str(#chan $chr(32),3) | halt }
  var %i 2 | while (%i <= $0) {
    var %chan $eval($+($,%i),2) 
    if ($left(%chan,1) != $chr(35)) { msg # 12Invalid channel name $+(4,%chan,12.) | inc %i } 
    elseif ($me ison %chan) { msg # 4 $+ $v1 12is already on $+(4,$v2,12.) | inc %i }
    else { $iif($regml(1) = go,join,part) %chan | inc %i }
  }
}

Comments

Sign in to comment.
ProIcons   -  Feb 23, 2014
 if (!$2) { notice $nick 12Syntax: $1 $str(#chan $chr(32),3) | halt }

Result:

Syntax: !command #chan #chan #chan wait what..?

It should be more like

Syntax: !command #chan[ #chan2 ... ]

Vegito  -  Feb 23, 2014

What do you mean?

Sign in to comment

Archie   -  Dec 15, 2013

You have over complicated this script. This script is also very messy. Thumbs up for trying but for overall structure, it's a thumbs down.

Vegito  -  Dec 15, 2013

Whats complicated about this script?
And whats messy?

Sign in to comment

Meta   -  Oct 13, 2013

You can place regex directly in the matchtext parameter of an event by placing a $ before the level (in this case, *) -- This will prevent the script from trying to trigger when it shouldn't, and also help avoid conflicts with other on text events in the same file:

*on $:TEXT:/^!(go|leave)$/Si:#: {**

 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.