| View previous topic :: View next topic |
| Author |
Message |
Riddler Halfop
Joined: 20 May 2007 Posts: 60 Location: Brasov, Romania
|
Posted: Wed Oct 31, 2007 12:34 am Post subject: A little question about "string" cmd |
|
|
Hello guy's,
I have a little problem with a string ... How do I set a "except" on a DCC CHAT string so that I wont get banned (when I`m trying to connect through partyline with the bot ) ?
I wanna except form banning only the ctcp key's "ACTION" and "DCC CHAT" .... for the rest, I want them banned
The Code
| Code: |
bind ctcp -|- * s:do:ctcp
proc s:do:ctcp { nick uhost handle target key args } {
global botnick work_chan
if {[string tolower $key]=="action"} {return 0}
if {[string tolower $key]=="dcc*chat"} {return 0}
putserv "PRIVMSG $work_chan :.2days *!*@[lindex [split $uhost @] 1] Drones/BOT's are banned."
}
|
Any little help pls, thanks ! _________________ I am a man of few words, but many riddles |
|
| Back to top |
|
 |
Riddler Halfop
Joined: 20 May 2007 Posts: 60 Location: Brasov, Romania
|
Posted: Wed Oct 31, 2007 7:14 pm Post subject: |
|
|
looks like nobody knows  _________________ I am a man of few words, but many riddles |
|
| Back to top |
|
 |
De Kus Revered One

Joined: 15 Dec 2002 Posts: 1361 Location: Germany
|
Posted: Wed Oct 31, 2007 7:18 pm Post subject: |
|
|
- "key" will never contain a white space
- the == operand doesn't support wildcards, you must use string match to do so.
- consider using string equal -nocase to begin with, when comparing string ignoring the case.
- if the key is "dcc" the keyword "chat" will be in [lindex $args 0].
- You can put them all into one if statement, if you use them in a statement like:
| Code: | | ![string equal -nocase $key "action"] && !([string equal -nocase $key "dcc"] && [string equal -nocase [lindex $args 0] "chat"]) | which should be true, in case you want them to be banned.
PS: you might want to rename "args" to "arg", because "args" might screw the lindex or require it to be doubled. I am currently not that familiar with the ctcp bind, but I suppose it might be that way. _________________ 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... |
|
| Back to top |
|
 |
Riddler Halfop
Joined: 20 May 2007 Posts: 60 Location: Brasov, Romania
|
Posted: Wed Oct 31, 2007 8:17 pm Post subject: |
|
|
ok, still not working
Error:
| Quote: | | (02:08:03) <@EGG> !ATENTIE!: Posibil SPAM prin CTCP de la Nickname [ident@hostname.users.undernet.org]: DCC CHAT chat 1380788232 1024 |
This message is not suppose to show, beacuse I`ve added the hostmask in to a except string
Code
| Code: |
### CONFIG ###
set spamdet(chat) "#channel"
set spamdet(except) {
"*!*@hostname.users.undernet.org"
"*!*@username.users.undernet.org"
}
### CODE ####
setudef flag spamdetective
bind ctcp -|- * s:do:ctcp
proc s:do:ctcp { nick uhost handle target key args } {
global botnick spamdet
set sms [lindex $args 0]
if {[string match *$uhost* $spamdet(except)]} { return 0 }
if {![string equal -nocase $key "action"] && !([string equal -nocase $key "dcc"] && [string equal -nocase [lindex $args 0] "chat"])} {
putserv "PRIVMSG $spamdet(chat) :\002!ATENTIE!\002: Posibil SPAM prin\002 CTCP \002de la\0032 $nick \003\[$uhost\]: $key $sms "
}
}
putlog "Loaded spamdet.tcl" |
Some more help ?! _________________ I am a man of few words, but many riddles |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Wed Oct 31, 2007 8:27 pm Post subject: |
|
|
Considder converting spamdet(except) to a list and use a foreach loop to match each list-item against the hostmask, rather than using a "string match" on the whole content.
If the list of hosts is stored in "hostlist", you could use something like this:
| Code: | foreach host $hostlist {
if {[string match $host "$nick!$uhost"]} {return 0}
} |
_________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
Riddler Halfop
Joined: 20 May 2007 Posts: 60 Location: Brasov, Romania
|
Posted: Wed Oct 31, 2007 10:14 pm Post subject: |
|
|
That's it nml375 , it's working
I`ve improve the code with some more facility's and run a cross a little issue with the utimer comand ...
The Problem:
| Quote: | (02:44:58) * Parts: EGG (id@domain.name) (looking for clues...)
(02:44:58) * Joins: EGG (id@domain.name)
(...)
(02:49:58) * Parts: EGG (id@domain.name) (looking for clues...)
(02:49:58) * Joins: EGG (id@domain.name)
(...)
and so on... |
The thing is that the bot is not following the $spamdet(gt) ( time to stay gone from the channel ) .... the actual part/join is within that second
The extended code:
| Code: | ### CONFIG ###
# main channel
set spamdet(mc) "#main_channel"
# alert channel
set spamdet(ac) "#alert_channel"
# cycle time [minutes]
set spamdet(ct) "5"
# gone time form the maine channel [seconds]
set spamdet(gt) "40"
# part message
set spamdet(pm) "looking for clues..."
# except from beeing banned
set spamdet(except) {
"*!*@hostname.users.undernet.org"
"*!*@username.users.undernet.org"
}
### CODE ####
bind ctcp -|- * s:do:ctcp
global spamdet
timer $spamdet(ct) s:cycle
proc s:cycle {} {
global botnick spamdet
putserv "PART $spamdet(mc) :$spamdet(pm)"
utimer $spamdet(gt) [list putserv "JOIN $spamdet(mc)"]
timer $spamdet(ct) s:cycle
}
proc s:do:ctcp { nick uhost handle target key args } {
global botnick spamdet
foreach host $spamdet(except) {
if {[string match $host "$nick!$uhost"]} {return 0}
}
if {![string equal -nocase $key "action"] && !([string equal -nocase $key "dcc"] && [string equal -nocase [lindex $args 0] "chat"])} {
set sms [lindex $args 0]
putserv "PRIVMSG $spamdet(ac) :\002!ATENTIE!\002: Posibil SPAM prin\002 CTCP \002de la\0032 $nick \003\[$uhost\]: $key $sms "
putserv "PRIVMSG $spamdet(mc) :.d 14 *!*@[lindex [split $uhost @] 1] Drones/BOT's are banned."
}
}
foreach checkutimer [utimers] {
if {[string match *cycle* [lindex $checkutimer 1]]} {
killutimer [lindex $checkutimer 2]
}
}
putlog "Loaded spamdet.tcl" |
What could be the problem ?!  _________________ I am a man of few words, but many riddles |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Thu Nov 01, 2007 8:49 am Post subject: |
|
|
Your bot will automatically rejoin any channel it is supposed to monitor, should it leave the channel for any other reason then the channel being either set +inactive or removed from the channel-list.
Rather than using putserv "PART ...", considder using something like this:
| Code: | channel set $spamdet(mc) +inactive
utimer $spamdet(gt) [list channel set $spamdet(mc) -inactive] |
_________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
Riddler Halfop
Joined: 20 May 2007 Posts: 60 Location: Brasov, Romania
|
Posted: Fri Nov 02, 2007 9:20 pm Post subject: |
|
|
Thanks nml375, the script works great  _________________ I am a man of few words, but many riddles |
|
| Back to top |
|
 |
|