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.

[REQ]Catch word and Send command after x time

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
b
bast
Voice
Posts: 37
Joined: Sat Oct 07, 2006 10:24 pm

[REQ]Catch word and Send command after x time

Post by bast »

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
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

This example should help you

Code: Select all

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"]
}
User avatar
iamdeath
Master
Posts: 323
Joined: Fri Feb 11, 2005 2:32 pm
Location: *HeLL*
Contact:

Post by iamdeath »

Sorry SirFz posting after your reply, actually I almost completed it so thought to paste it, excuse me for that:

Code: Select all

#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.
m
metroid
Owner
Posts: 771
Joined: Wed Jun 16, 2004 2:46 am

Post by metroid »

It won't work either anyway.
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

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: Select all

#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
User avatar
iamdeath
Master
Posts: 323
Joined: Fri Feb 11, 2005 2:32 pm
Location: *HeLL*
Contact:

Post by iamdeath »

erm. metroid maybe because of 1

Code: Select all

}
left in the end I guess, right?
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

@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
r
r0t3n
Owner
Posts: 507
Joined: Tue May 31, 2005 6:56 pm
Location: UK

Post by r0t3n »

nml375, there is an error in your script:

Code: Select all

foreach yourwords $yourwords { 
You could try this solution...

Code: Select all

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
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

@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
b
bast
Voice
Posts: 37
Joined: Sat Oct 07, 2006 10:24 pm

Post by bast »

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. :D
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

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
b
bast
Voice
Posts: 37
Joined: Sat Oct 07, 2006 10:24 pm

Post by bast »

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.
Post Reply