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.

bot chanmode informer

Help for those learning Tcl or writing their own scripts.
Post Reply
User avatar
spithash
Master
Posts: 248
Joined: Thu Jul 12, 2007 9:21 am
Location: Libera
Contact:

bot chanmode informer

Post by spithash »

I have a script that informs me if the bot got banned on any channel by private msging me, I got it from an other topic, I forgot which one..

The code is this:

Code: Select all

bind mode * "% +b" check:ban
proc check:ban {nick uhost handle channel change target} {
   # check if the mask matches the bot's host and return if it doesn't
   if {![string match -nocase $target $::botname]} return
   # do what action/actions you wish as the mask matches his host
   putserv "PRIVMSG spithash :Yo, I am banned on $channel !!!"
}
The question is, how can I make it inform me if it even gets voiced/devoiced and opped/deopped too?

Thank you, it will be really helpful to me and a piece of cake for you coders :)
Libera ##rtlsdr & ##re - Nick: spithash
Click here for troll.tcl
User avatar
arfer
Master
Posts: 436
Joined: Fri Nov 26, 2004 8:45 pm
Location: Manchester, UK

Post by arfer »

Untested but I think it's OK

Code: Select all

bind MODE - * check:mode

proc check:mode {nick uhost handle channel change target} {
    if {[string equal -nocase $target $::botnick]} {
        switch -- $change {
            "+o" {putserv "PRIVMSG spithash :Yo, I have been oped by $nick on $channel !!!"}
            "-o" {putserv "PRIVMSG spithash :Yo, I have been deoped by $nick on $channel !!!"}
            "+v" {putserv "PRIVMSG spithash :Yo, I have been voiced by $nick on $channel !!!"}
            "-v" {putserv "PRIVMSG spithash :Yo, I have been devoiced by $nick on $channel !!!"}
            default {}
        }
    } else {
        if {([string equal $change "+b"]) && ([string match -nocase $target $::botname])} {
            putserv "PRIVMSG spithash :Yo, I have been banned by $nick on $channel !!!"
        }
    }
    return 0
} 
The one drawback, if you consider it such, is that coded in this way causes the bot to check every mode change on every channel.
I must have had nothing to do
User avatar
spithash
Master
Posts: 248
Joined: Thu Jul 12, 2007 9:21 am
Location: Libera
Contact:

Post by spithash »

Thanks a lot man, it works like a charm :)

It's really helpful/useful to me :D
Libera ##rtlsdr & ##re - Nick: spithash
Click here for troll.tcl
User avatar
spithash
Master
Posts: 248
Joined: Thu Jul 12, 2007 9:21 am
Location: Libera
Contact:

Post by spithash »

hrmm, how about kick informing? That would complete it I think :)
Libera ##rtlsdr & ##re - Nick: spithash
Click here for troll.tcl
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

Try adding this to your script...

Code: Select all

bind kick - *$botnick* check:kick

proc check:kick {nick uhost handle channel target reason} { 
    if {[string equal -nocase $target $::botnick]} { 
        putserv "PRIVMSG spithash :Yo, I have been kicked by $nick on $channel !!!" 
    }
}
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

How about using internal isbonick function instead of:

Code: Select all

if {[string equal -nocase $target $::botnick]} {
like this:

Code: Select all

if {[isbotnick $target]} {
that would work only if there's a single mode change per line (like -v bot), thus you would need (not tested, but in theory) to use lsearch or a foreach loop with a isbotnick check that is basically the same thing with the lsearch instead.
Once the game is over, the king and the pawn go back in the same box.
User avatar
spithash
Master
Posts: 248
Joined: Thu Jul 12, 2007 9:21 am
Location: Libera
Contact:

Post by spithash »

Really thank you guys, it works like a charm :)

caesar: works as well, thanks :)
Libera ##rtlsdr & ##re - Nick: spithash
Click here for troll.tcl
Post Reply