Timed ban/mute for bot

By Wizjany on Jul 27, 2008

I was looking for a timed ban for my bot, but they were all the nicklist type, so I made this one.

to use it:
!tb nick time reason
the time is in minutes, and a reason is optional

Being one of my first scripts, constructive criticism is welcomed.

I updated it to include a gag. You might see that I used two timers. This is because when I used one, the second command got executed immediately, instead of waiting for the timer. You are free to take it out if you can make it work.

On @10:Text:!tb *:#: {
  if (!$2) || ($2 !ison $chan) { msg $chan $iif(!$2,You did not specify a nick to ban.,They aren't in this channel. }
  elseif (!$3) || ($3 !isnum 1-120) { msg $chan Please enter a number between 1 and 120. This will be the number of minutes they are banned. } 
else { 
    msg $chan $2 has been banned for $3 minutes. $iif($4,Reason: $4-)
    ban -ku $+ $calc($3 * 60) $chan $2 5   
  }
}

On @10:Text:!tm *:#: {
  if (!$2) || ($2 !ison $chan) { msg $chan $iif(!$2,You did not specify a nick to gag.,They aren't on this channel. }
  elseif (!$3) || ($3 !isnum 1-120) { msg $chan Please enter a number between 1 and 120. This will be the number of minutes they are gagged. }
  else { 
    msg $chan $2 has been gagged for $3 minutes. $iif($4,Reason: $4-)
    set %tmaddress ~q: $+ $address($2,5) 
    mode $chan +b %tmaddress
    /timergag 1 $calc($3 * 60) /mode $chan -b %tmaddress
    /timergag2 1 $calc(($3 * 60) + 1 ) msg $chan $2 may now speak again.
  }
}

Comments

Sign in to comment.
xplo   -  Jul 31, 2008

Type Rules at msl101 :)

*note msl stands for mirc scripting language (For the new people)

LMAO

actually, imm just really stone and i wanted to post a random comment :D

 Respond  
Typo   -  Jul 28, 2008

Also in the future dont forget about the forums. Theyre a great place to get help perfecting a script before you release it or to just get some simple advice to help you with your code.

Keep it up. :)

 Respond  
Wizjany   -  Jul 28, 2008

Alright great. I fixed the $3 thing (you told me to in your second tip but didn\'t cut it out) and used napa\'s $iif for the $2 thing. It should be working now.

 Respond  
irchainscriptz   -  Jul 28, 2008

Nice work typo. Very good explanation of code fix.

 Respond  
Typo   -  Jul 28, 2008

Ok, Im going to give you a hand.
First: Get rid of the halts and use another else to make it so we dont need them.
Second: Change

elseif (!$3) || ($3 !isnum) || ($3 > 120) || ($3 < 1)

into

elseif ($3 isnum 1-120)

since its all thats needed there.
Third: We need to get the commands each on its own line so its easier to figure out problems when they occur.
Fourth: Get rid of the settings that you dont neet and btw in the future you should use /var in situations like these so it unsets itself when the script is done.
Fifth: Fix the ban command to do the kick
Sixth: Use a $iif to add the reason to the end of the message if it exists instead of using a whole seperate else section.
Lastly: Get rid of the /\'s since they arent needed inside scripts.
So your code before was:

On @10:Text:!tb *:#: {
  if ($2 !ison $chan) { msg $chan They aren\'t in this channel. | halt }
  if (!$2) { msg $chan You did not specify a nick to ban. | halt }
  elseif (!$3) || ($3 !isnum) || ($3 > 120) || ($3 < 1) { msg $chan Please enter a number between 1 and 120. This will be the number of minutes they are banned. | halt }  
  elseif (!$4) { 
    set $tbnick $2 | set $tbtime $calc($3 * 60) | msg $chan $tbnick has been banned for $3 minutes. | /ban -u $+ $tbtime $+ K $chan $tbnick 5 | halt }
  else { 
    set $tbnick $2 | set $tbreason $4- | set 4tbtime $calc($3 * 60) | msg $chan $tbnick has been banned for $3 minutes. Reason: $tbreason | /ban -u $+ $tbtime $+ K $chan $tbnick 5 | halt   
  }
}

And after all the fixes its:

On @10:Text:!tb *:#: {
  if ($2 !ison $chan) { msg $chan They aren\'t in this channel. }
  elseif (!$2) { msg $chan You did not specify a nick to ban. }
  elseif (!$3) || ($3 !isnum) || ($3 > 120) || ($3 < 1) { msg $chan Please enter a number between 1 and 120. This will be the number of minutes they are banned. | halt }  
else {  
    msg $chan $2 has been banned for $3 minutes. $iif($4,Reason: $4-)
    ban -ku $+ $calc($3 * 60) $chan $2 5   
  }
}

That should fix all your problems.

I included your original code above the new code so you could easily compare them. Take a few minutes to see exactly what I did and learn from it.

Good luck.

 Respond  
Wizjany   -  Jul 28, 2008

alright thanks a lot, it all got worse when russelB told me to edit it...no offense, but I don\'t understand what he\'s trying to tell me -.-

 Respond  
napa182   -  Jul 27, 2008

ur script dont work im getting errors

  • /set: invalid parameters (line 11)
  • /set: invalid parameters (line 13)

you are setting ur vars wrong you are doing set $tbreason and so on it should be set %tbreason also there is no reason to set any vars at all for this.
Wizjany said:

Also, you say that some IRCds require a kick reason, even when using the k switch of the /ban, but I don\'t know where the reason would go, as it\'s not mentioned in the syntax...
um it would be

ban -k # $nick 5 reason here

you can do it like this as well

on @10:text:!tb*:#:{
  if ($2 !ison #) || (!$2) { msg $chan $iif(!$2,Please Enter A Nick To Ban.,Sorry But I Can\'t Seem To Find $2 $+ .) } 
  elseif ($3 !isnum 1-60) || (!$4) { msg $chan $iif($3 !isnum 1-60,Please Enter Number Of Minute\'s To Ban 1 - 60.,Please Enter A Reason To Ban.) } 
  else { ban -ku $+ $calc($3 * 60) # $2 2 $4- }
}

i scored ur snippet a 2 for being incomplete

 Respond  
Wizjany   -  Jul 27, 2008

Alright, I fixed most of it except for a few things.

First, if you mean using a .msg instead of msg | halt I tried that already, but it didn\'t getting through the testing stages...it continued to run through my script and banned them twice, once without the reason and once with it.
Also, you say that some IRCds require a kick reason, even when using the k switch of the /ban, but I don\'t know where the reason would go, as it\'s not mentioned in the syntax...

 Respond  
RusselB   -  Jul 27, 2008

Suggestions:
1) Use proper if/elseif/else format. This will enable you to remove the halt statments, which can cause problems with other scripts
2) Ensure that $3 is a number and a reasonable number at that. You probably don\'t want someone doing a !tb 99999999999999999999999999999999999999999999999999999
3) modify the /ban command to include the k switch which will allow you to remove the /kick command.
4) No need to use %tbaddress as the /ban command can use the nick and the mask 5 moderator.
5) Use local variables rather than global, allowing you to eliminate the unset routine
6) Include the @ character in front of the 10 in the ON TEXT event to ensure that the client running the code has ops in the channel
7) While you state that reason is optional, most IRCd\'s require a reason as part of the /kick command (whether issued separately, as you currently have it, or using the k switch in the /ban command as I have suggested)

 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.