This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Need help with anti ban/deop script

Old posts that have not been replied to for several years.
Locked
D
Dizzle
Op
Posts: 109
Joined: Thu Apr 28, 2005 11:21 am
Contact:

Need help with anti ban/deop script

Post by Dizzle »

Hi, im learning how too script on my own, and i was making this script, butt it aint working,

the bot is rejoining the channel, butt he aint banning the user who did it, hes just rejoining, can somebody give me some advice what too do ?

here's the script

Code: Select all

set globalbantime "120"

set banmsg "Dont ban me dude, 120 minutes banned 

set kickmsg "[censored] off"

setudef flag banpunish
setudef flag banprot
bind mode - * check_modes
proc check_modes {nick uhost hand chan mode arg} {
   global botnick kickmsg globalbantime
   foreach i [channel info $chan] {
      if {([onchan L $chan])} {
         if {([string match "+banpunish" $i])} {
            if {($mode == "-o") && ($arg == $botnick) && ($nick != "*.quakenet.org")} {
               putserv "PRIVMSG L :unbanall $chan"
               puthelp "JOIN $chan"
               putserv "PRIVMSG L :op $chan"
               utimer 3 [list putserv "MODE $chan -o $nick"]
               utimer 5 [list putserv "MODE $chan +b $nick *!$uhost"]
               utimer 7 [list putserv "KICK $chan $nick :$banmsg"]
               timer $globalbantime [subst {putserv "MODE $chan -b *!$uhost"}]
            } else {
               if {($mode == "+b") && ($arg == $botnick) && ($nick != "*.quakenet.org")} {
                  putserv "PRIVMSG L :unbanall $chan"
                  puthelp "JOIN $chan"
                  putserv "PRIVMSG L :op $chan"
                  utimer 3 [list putserv "MODE $chan -o $nick"]
                  utimer 5 [list putserv "MODE $chan +b $nick *!$uhost"]
                  utimer 7 [list putserv "KICK $chan $nick :$banmsg"]
                  timer $globalbantime [subst {putserv "MODE $chan -b *!$uhost"}]
               }
            }
         } else {
            if {([string match "+banprot" $i])} {
               if {($mode == "-o") && ($arg == $botnick) && ($nick != "*.quakenet.org")} {
                  putserv "PRIVMSG L :unbanall $chan"
                  puthelp "JOIN $chan"
                  putserv "PRIVMSG L :op $chan"
                  utimer 3 [list putserv "MODE $chan -o $nick"]
                  utimer 5 [list putserv "KICK $chan $nick :$banmsg"]
                  timer $globalbantime [subst {putserv "MODE $chan -b *!$uhost"}]
               } else {
                  if {($mode == "+b") && ($arg == $botnick) && ($nick != "*.quakenet.org")} {
                     putserv "PRIVMSG L :unbanall $chan"
                     puthelp "JOIN $chan"
                     putserv "PRIVMSG L :op $chan"
                     utimer 3 [list putserv "MODE $chan -o $nick"]
                     utimer 5 [list putserv "KICK $chan $nick :$banmsg"]
                     timer $globalbantime [subst {putserv "MODE $chan -b *!$uhost"}]
                  }
               }
            }
         }
      } else {
         if {([onchan Q $chan])} {
            if {([string match "+banpunish" $i])} {
               if {($mode == "-o") && ($arg == $botnick) && ($nick != "*.quakenet.org")} {
                  putserv "PRIVMSG Q :unban $bothost"
                  puthelp "JOIN $chan"
                  putserv "PRIVMSG Q :op $chan"
                  utimer 3 [list putserv "MODE $chan -o $nick"]
                  utimer 5 [list putserv "MODE $chan +b $nick *!$uhost"]
                  utimer 7 [list putserv "KICK $chan $nick :$banmsg"]
                  timer $globalbantime [subst {putserv "MODE $chan -b *!$uhost"}]
               } else {
                  if {($mode == "+b") && ($arg == $botnick) && ($nick != "*.quakenet.org")} {
                     putserv "PRIVMSG Q :unban $bothost"
                     puthelp "JOIN $chan"
                     putserv "PRIVMSG Q :op $chan"
                     utimer 3 [list putserv "MODE $chan -o $nick"]
                     utimer 5 [list putserv "MODE $chan +b $nick *!$uhost"]
                     utimer 7 [list putserv "KICK $chan $nick :$banmsg"]
                     timer $globalbantime [subst {putserv "MODE $chan -b *!$uhost"}]
                  }
               }
            } else {
               if {([string match "+banprot" $i])} {
                  if {($mode == "-o") && ($arg == $botnick) && ($nick != "*.quakenet.org")} {
                     putserv "PRIVMSG Q :unban $bothost"
                     puthelp "JOIN $chan"
                     putserv "PRIVMSG Q :op $chan"
                     utimer 3 [list putserv "MODE $chan -o $nick"]
                     utimer 5 [list putserv "KICK $chan $nick :$banmsg"]
                     timer $globalbantime [subst {putserv "MODE $chan -b *!$uhost"}]
                  } else {
                     if {($mode == "+b") && ($arg == $botnick) && ($nick != "*.quakenet.org")} {
                        putserv "PRIVMSG Q :unban $bothost"
                        puthelp "JOIN $chan"
                        putserv "PRIVMSG Q :op $chan"
                        utimer 3 [list putserv "MODE $chan -o $nick"]
                        utimer 5 [list putserv "KICK $chan $nick :$banmsg"]
                        timer $globalbantime [subst {putserv "MODE $chan -b *!$uhost"}]
                     }
                  }
               }
            }
         }
      }
   }
}
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

if {($mode == "+b") && ($arg == $botnick) && ($nick != "*.quakenet.org")}
this contains 2 logical and 1 syntactical errors:
1st: $arg will never be $botnick, even if someone bans the bot by nick it will be 'botnick!*@* != botnick'.
2nd: $nick will never be *.quakenet.org (besides == string comparsions are not using wildcards anyway), if it is a server mode $nick will an emtpy string and $uhost will contain something like "blueyonder2.uk.quakenet.org" and match "*.quakenet.org", but it still will never be equal to "*.quakenet.org" ^-^
3rd: the open quote after if MUST be in the same line than if itself (you dont have a command end character like in C, php, etc.)

overall suggestions:
1st: trash your foreach structure and the [string match "+banpunish" $i] thing and use this for check:

Code: Select all

if { [lsearch -exact [channel info $chan] "+banpunish"] != -1 } {
   ...
}
2nd: dont use UNBANALL, this will only unball all previos banned offenders as well. use INVITE instead (you spare the JOIN command, since the bot will follow the invite automatically). many overtakes ban, set invite + key and maybe even +l, but INVITE will own all :).
Last edited by De Kus on Thu Apr 28, 2005 11:52 am, edited 4 times in total.
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

I just skimmed through your code, if I'm not wrong you're relaying on utimer to do the deop, but what if the bot didn't get ops during this period of time ?

My suggestion is to add the nick to an array so once the bot regains op, it checks if info exists for the array and does the commands.
m
metroid
Owner
Posts: 771
Joined: Wed Jun 16, 2004 2:46 am

Post by metroid »

using channel get <channel> <flag> seems smarter to use than lsearch though
Locked