egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

bot chanmode informer

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
spithash
Master


Joined: 12 Jul 2007
Posts: 248
Location: Libera

PostPosted: Fri Oct 26, 2012 7:19 am    Post subject: bot chanmode informer Reply with quote

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:
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 Smile
_________________
Libera ##rtlsdr & ##re - Nick: spithash
Click here for troll.tcl
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
arfer
Master


Joined: 26 Nov 2004
Posts: 436
Location: Manchester, UK

PostPosted: Fri Oct 26, 2012 7:54 pm    Post subject: Reply with quote

Untested but I think it's OK

Code:

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
Back to top
View user's profile Send private message
spithash
Master


Joined: 12 Jul 2007
Posts: 248
Location: Libera

PostPosted: Sun Oct 28, 2012 6:11 am    Post subject: Reply with quote

Thanks a lot man, it works like a charm Smile

It's really helpful/useful to me Very Happy
_________________
Libera ##rtlsdr & ##re - Nick: spithash
Click here for troll.tcl
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
spithash
Master


Joined: 12 Jul 2007
Posts: 248
Location: Libera

PostPosted: Mon Nov 12, 2012 11:07 am    Post subject: Reply with quote

hrmm, how about kick informing? That would complete it I think Smile
_________________
Libera ##rtlsdr & ##re - Nick: spithash
Click here for troll.tcl
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
SpiKe^^
Owner


Joined: 12 May 2006
Posts: 792
Location: Tennessee, USA

PostPosted: Mon Nov 12, 2012 7:30 pm    Post subject: Reply with quote

Try adding this to your script...

Code:
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
.
Back to top
View user's profile Send private message Visit poster's website
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Fri Nov 16, 2012 2:41 am    Post subject: Reply with quote

How about using internal isbonick function instead of:
Code:

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

like this:
Code:

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.
Back to top
View user's profile Send private message
spithash
Master


Joined: 12 Jul 2007
Posts: 248
Location: Libera

PostPosted: Fri Nov 16, 2012 2:15 pm    Post subject: Reply with quote

Really thank you guys, it works like a charm Smile

caesar: works as well, thanks Smile
_________________
Libera ##rtlsdr & ##re - Nick: spithash
Click here for troll.tcl
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber