Code: Select all
bind pub o|o .ban pub:ban
bind pub o|o .unban pub:ub
proc pub:ban {nick uhost hand chan text} {
if {[string length $text] > 0} {
set tnick [lindex [split $text] 0]
if {[onchan $tnick $chan]} {
if {[llength [split $text]] == 1} { set reason banned } else { set reason [join [lrange [split $text] 1 end]] }
putserv "privmsg x :ban $chan $tnick 1 100 $reason"
} else { puthelp "notice $nick :I cannot ask X to ban $tnick. They are not on $chan." }
} else { puthelp "notice $nick :Please use proper format. Usage .ban <nick> \[<reason>\]" }
}
proc pub:ub {nick uhost hand chan text} {
if {[string length $text] > 0} {
set tnick [lindex [split $text] 0]
putserv "privmsg x :unban $chan $tnick"
} else { puthelp "notice $nick :Please use proper format. Usage .ban <nick> \[<reason>\]" }
}
Norton goofed, he has it check ( if [botisop $chan] == 0 ) and then perform the banning or unbanning. Problem is, that equation will only be true when the bot is NOT opped, and will cry to X to do the banning when it isn't opped. If the bot is opped, this script will do absolutely nothing (except message you "algo falla" (aka, something went wrong)), not quite what you had in mind. This check is NOT necessary since using X the bot can be opped or unopped and it will work. This is how the code above is written, without needless checks. Also corrected norton's flawed string/list manipulations which will cause problems for you with nicknames/reasons containing special characters. This is a very simple script, I've removed the part where eggdrop tries to add bans to it's internal ban list and have it only set these via X (so if opped your eggdrop won't fight with X to kick/ban people). You might have a problem when removing bans, because the script doesn't check just asks X to remove the ban. There are better X manipulation scripts available, this is just something to show you how to fish correctly. You can give a man a fish, and feed him for a day. Or you can teach a man to fish, and feed him for a lifetime. Tcl is alot like fishing to me...The forum is akin to a very big lake filled with vast varieties of fish. This attracts many talented fisherman. The advice given by these fisherman is second to none, there is much you can learn from them. A script is a fish. Anyone can ask for a fish, it takes a true talented fisherman to bring one safely onto the shore without hooking it through the eye, or the gills or any other mangling of the fish.
Keep in mind to use this, you bot must have access level high enough to ban and be known and identified through X.