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.
Help for those learning Tcl or writing their own scripts.
Riddler
Halfop
Posts: 60 Joined: Sun May 20, 2007 10:20 pm
Location: Brasov, Romania
Contact:
Post
by Riddler » Wed Oct 31, 2007 12:34 am
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: Select all
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
Riddler
Halfop
Posts: 60 Joined: Sun May 20, 2007 10:20 pm
Location: Brasov, Romania
Contact:
Post
by Riddler » Wed Oct 31, 2007 7:14 pm
looks like nobody knows
I am a man of few words, but many riddles
De Kus
Revered One
Posts: 1361 Joined: Sun Dec 15, 2002 11:41 am
Location: Germany
Post
by De Kus » Wed Oct 31, 2007 7:18 pm
"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: Select all
![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...
Riddler
Halfop
Posts: 60 Joined: Sun May 20, 2007 10:20 pm
Location: Brasov, Romania
Contact:
Post
by Riddler » Wed Oct 31, 2007 8:17 pm
ok, still not working
Error:
This message is not suppose to show, beacuse I`ve added the hostmask in to a except string
Code
Code: Select all
### 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
nml375
Revered One
Posts: 2860 Joined: Fri Aug 04, 2006 2:09 pm
Post
by nml375 » Wed Oct 31, 2007 8:27 pm
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: Select all
foreach host $hostlist {
if {[string match $host "$nick!$uhost"]} {return 0}
}
NML_375
Riddler
Halfop
Posts: 60 Joined: Sun May 20, 2007 10:20 pm
Location: Brasov, Romania
Contact:
Post
by Riddler » Wed Oct 31, 2007 10:14 pm
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:
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: Select all
### 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
nml375
Revered One
Posts: 2860 Joined: Fri Aug 04, 2006 2:09 pm
Post
by nml375 » Thu Nov 01, 2007 8:49 am
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: Select all
channel set $spamdet(mc) +inactive
utimer $spamdet(gt) [list channel set $spamdet(mc) -inactive]
NML_375
Riddler
Halfop
Posts: 60 Joined: Sun May 20, 2007 10:20 pm
Location: Brasov, Romania
Contact:
Post
by Riddler » Fri Nov 02, 2007 9:20 pm
Thanks nml375, the script works great
I am a man of few words, but many riddles