| View previous topic :: View next topic |
| Author |
Message |
bast Voice
Joined: 07 Oct 2006 Posts: 37
|
Posted: Fri Mar 30, 2007 5:09 pm Post subject: [REQ]Catch word and Send command after x time |
|
|
Hey guys.
Is it possible to get a script that could catch a specific word in a channel and execute a command after a period of time.
ex.
user1: hey, im a n00b
Scripts checks n00b, and hold that for 10 min then it execute a command in a specifik chan.
!kick sorry, n00bs aint alllowed in here |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Fri Mar 30, 2007 7:44 pm Post subject: |
|
|
This example should help you
| Code: | bind pubm - "% *n00b*" time:kick
proc time:kick {nick uhost hand chan arg} {
timer 10 [list putserv "kick $chan $nick :sorry, n00bs aint alllowed in here"]
} |
_________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
iamdeath Master

Joined: 11 Feb 2005 Posts: 323 Location: *HeLL*
|
Posted: Fri Mar 30, 2007 8:15 pm Post subject: |
|
|
Sorry SirFz posting after your reply, actually I almost completed it so thought to paste it, excuse me for that:
| Code: | #Channel to perform command on.
set yourchannel "#channel"
#Add your kick reason here.
set yourkick "Your kick reason comes here."
#Add your words here.
set yourwords {
"n00b"
"sh00b"
"toob"
}
bind pubm - * yourproc
proc ccodes:filter {str} {
regsub -all -- {\003([0-9]{1,2}(,[0-9]{1,2})?)?|\017|\037|\002|\026|\006|\007} $str "" str
return $str
}
proc yourproc {nick uhost handle channel args} {
global yourchannel yourkick yourwords
set args [ccodes:filter $args]
foreach yourwords [string tolower $yourwords] {
if {[string match *$yourwords* [string tolower $args]]} {
timer 10 [list putserv "KICK $yourchannel $nick :$yourkick"]
}
}
putlog "TCL loaded." |
Hey I have'nt tested it. |
|
| Back to top |
|
 |
metroid Owner
Joined: 16 Jun 2004 Posts: 771
|
Posted: Sat Mar 31, 2007 4:51 am Post subject: |
|
|
| It won't work either anyway. |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Sat Mar 31, 2007 7:23 am Post subject: |
|
|
A proper and fixed version of the script posted by iamdeath, depends on tcl8.2 or newer (for the -nocase matching) and eggdrop1.6.17 or newer (for stripcodes):
| Code: | #Add your kick reason here.
set yourkick "Your kick reason comes here."
#Add your words here.
set yourwords [list "n00b" "sh00b" "toob"]
bind pubm - * yourproc
proc yourproc {nick uhost handle channel text} {
global yourchannel yourkick yourwords
set text [stripcodes "c" $text]
foreach yourwords $yourwords {
if {[string match -nocase "*$yourwords*" $text]} {
timer 10 [list putserv "KICK $channel $nick :$yourkick"]
break
}
}
} |
In any case, I'd probably stick with Sir_FZ's version; simpler, less prone to errors. _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
iamdeath Master

Joined: 11 Feb 2005 Posts: 323 Location: *HeLL*
|
Posted: Sat Mar 31, 2007 8:31 am Post subject: |
|
|
| erm. metroid maybe because of 1 left in the end I guess, right? |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Sat Mar 31, 2007 9:05 am Post subject: |
|
|
@iamdeath:
Actually, your code would trigger on any channel, but do the kick in a predefined channel. In case someone used multiple triggers in a single message, this would stack kick-timers causing unneccesary penalty points (I admit, even the fixed code does not check for pre-existing timers on subsecuencial messages). "args" is a special variable name when used in proc-declarations, accepting an arbitrary number of arguments (each added to args as a separate list-item), and should really be avoided unless this behaviour is explicitly desired. It is also not such a good idea to use string commands such as "string tolower" on list structures, as these will also modify the delimiter characters (such as {}) in some cases. Finally, don't ever use list commands such as foreach on non-lists (strings).
One thing worth mentioning however, is that none of the current "solutions" handle the case of "badboy" changing nick after writing a bad word, hence avoiding being kicked, and also possibly getting someone else kicked. _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
r0t3n Owner
Joined: 31 May 2005 Posts: 507 Location: UK
|
Posted: Sat Mar 31, 2007 10:24 am Post subject: |
|
|
nml375, there is an error in your script:
| Code: | | foreach yourwords $yourwords { |
You could try this solution...
| Code: | set yourchans [list "#chan1" "#chan2" "#chan3"]
set yourkmsg "Sorry, no :word:s allowed here"
set yourwords [list "n00b" "blah" "blib"]
set yourtime "60"; # in seconds
if {![array exists yournicklist]} {
array set yournicklist {}
}
bind pubm -|- {*} yourword
bind nick -|- {*} yournick
proc yournick {nick uhost hand chan newnick} {
global yourchans yournicklist yourtime
if {[lsearch -exact "$yourchans" $chan] == -1} { return }
if {![info exists yournicklist($chan:$nick)]} { return }
catch {killutimer [lindex [split $yournicklist($chan:$nick)] 0]}
set word [lindex [split $yournicklist($chan:$nick)] 1]
unset yournicklist($chan:$nick)
set yournicklist($chan:$nick) "[utimer $yourtime [list yourkick $chan $nick $word]] $word"
}
}
proc yourword {nick uhost hand chan text} {
global yourchans yournicklist yourwords yourtime
if {[lsearch -exact "$yourchans" $chan] == -1} { return }
if {[info exists yournicklist($chan:$nick]} { return }
set match "0"
foreach word $yourwords {
if {[string match -nocase *$word* $text]} {
set match $word
break
}
}
if {$match == "0"} { return }
set yournicklist($chan:$nick) "[utimer $yourtime [list yourkick $chan $nick $match]] $match"
}
proc yourkick {chan nick word} {
if {[lsearch -exact "$yourchans" $chan] == -1} { return }
if {[onchan $nick $chan] && [botisop $chan]} {
regsub -all :word: $yourkmsg "$word" kmsg
putserv "KICK $chan $nick :$kmsg"
}
unset yournicklist($chan:$nick)
} |
Its not tested, it might work.. it might not, but its mainly a base you can build on... _________________ r0t3n @ #r0t3n @ Quakenet |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Sat Mar 31, 2007 10:34 am Post subject: |
|
|
@Tosser^^:
It is fully functional, but maybe not recommendable in the sence of keeping the code clean. Nice catch anyway
One thing tho, is'nt the case of $chan in yourword dependant on the case used by the user triggering the commands, rather than the case it was added to the bot? _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
bast Voice
Joined: 07 Oct 2006 Posts: 37
|
Posted: Sat Mar 31, 2007 4:46 pm Post subject: |
|
|
nice work guys.
But. =)
i dont think i said it clear enogh thou. =)
The kick was just an exampel.
I want it to send a command Or just a sentence in a specifik chan. and i want it to monitor one specifik chan, and i forgot to tell that it need to catch the word and set it in the command i want to send.
ex. 1
<user> Hey, im a n00b
<bot> triggers on Hey
and then it sends !command the word n00b isnt allowed
ex 2
<user> Hey, im a wanker
<bot> triggers on Hey
and then it send !command the word wanker isnt allowed
so it should trigger on Hey and catch both wanker and n00b and set this into whatever command i want to send.
i hope this can be done. ugly or a nice way dosent matter.  |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Sat Mar 31, 2007 4:50 pm Post subject: |
|
|
Well, in that case you'd just have to alter the message sent with putserv from something like "KICK $chan $nick :blah" into "PRIVMSG $chan :!kick $nick blah". $nick and $chan of course would depend on the actual script, as different examples in this thread choose different names for those arguments.
But in essence, putserv sends whatever string you supply to the irc-server without further parsing. _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
bast Voice
Joined: 07 Oct 2006 Posts: 37
|
Posted: Mon Apr 02, 2007 4:37 pm Post subject: |
|
|
ok, i cant a [censored] of this scripting thingy. =)
But the above script is almost what i want.
But i want it to trigger on "myword" and put the second word in my command.
hey looser
triggers on hey, takes looser and put it in my command.
hey dick
triggers on hey, takes dick and put it in my command.
so it should trigger on a specific word i set and takes whatever other word that comes second and put it in my command.
=)
and monitor one chan and send the command in another chan. |
|
| Back to top |
|
 |
|