| View previous topic :: View next topic |
| Author |
Message |
spithash Master

Joined: 12 Jul 2007 Posts: 248 Location: Libera
|
Posted: Fri Oct 26, 2012 7:19 am Post subject: bot chanmode informer |
|
|
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  _________________ Libera ##rtlsdr & ##re - Nick: spithash
Click here for troll.tcl |
|
| Back to top |
|
 |
arfer Master

Joined: 26 Nov 2004 Posts: 436 Location: Manchester, UK
|
Posted: Fri Oct 26, 2012 7:54 pm Post subject: |
|
|
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 |
|
 |
spithash Master

Joined: 12 Jul 2007 Posts: 248 Location: Libera
|
Posted: Sun Oct 28, 2012 6:11 am Post subject: |
|
|
Thanks a lot man, it works like a charm
It's really helpful/useful to me  _________________ Libera ##rtlsdr & ##re - Nick: spithash
Click here for troll.tcl |
|
| Back to top |
|
 |
spithash Master

Joined: 12 Jul 2007 Posts: 248 Location: Libera
|
Posted: Mon Nov 12, 2012 11:07 am Post subject: |
|
|
hrmm, how about kick informing? That would complete it I think  _________________ Libera ##rtlsdr & ##re - Nick: spithash
Click here for troll.tcl |
|
| Back to top |
|
 |
SpiKe^^ Owner

Joined: 12 May 2006 Posts: 792 Location: Tennessee, USA
|
Posted: Mon Nov 12, 2012 7:30 pm Post subject: |
|
|
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 |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Fri Nov 16, 2012 2:41 am Post subject: |
|
|
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 |
|
 |
spithash Master

Joined: 12 Jul 2007 Posts: 248 Location: Libera
|
Posted: Fri Nov 16, 2012 2:15 pm Post subject: |
|
|
Really thank you guys, it works like a charm
caesar: works as well, thanks  _________________ Libera ##rtlsdr & ##re - Nick: spithash
Click here for troll.tcl |
|
| Back to top |
|
 |
|