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.

[solved] Regex help - cant get my head around this

Help for those learning Tcl or writing their own scripts.
Post Reply
d
doggo
Halfop
Posts: 97
Joined: Tue Jan 05, 2010 7:53 am
Contact:

[solved] Regex help - cant get my head around this

Post by doggo »

i have a script running i one channel that has lots of spam info in , that relays certain parts of that info to another channel over the bot net,

but i know need somthing with regex /me is a n00b with regex,

the bots name i want to monitor is inner-b0t and when this line is said on my $chan it will strip out just the request id number, ie :


Code: Select all

 <inner-b0t> That was awesome [*Anonymous*] Shall we do it again? ReqId:[126556]
and then MSG $another_channel

Code: Select all

 -send $req-number
so in $another_channel it would read

Code: Select all

 <inner-b0t> -send 126556   
the line is always the same but the reqid is different and i have no clue how to script this :(


thanks guys hope someone can help me :)
Last edited by doggo on Mon May 24, 2010 4:26 pm, edited 1 time in total.
User avatar
tomekk
Master
Posts: 255
Joined: Fri Nov 28, 2008 11:35 am
Location: Oswiecim / Poland
Contact:

Post by tomekk »

Code: Select all

set the_nick "tomekk"

##############################################
bind pubm -|- "*" check_line

proc check_line { nick uhost hand chan arg } {
        global the_nick

        if {$the_nick == $nick} {
                if {[regsub -all -nocase {.*ReqId:\[(.*)\].*} $arg {\1} arg]} {
                        putquick "PRIVMSG $chan :ReqId echo -> $arg"
                }
        }
}

putlog "whatever.tcl loaded"
17:36:48 <@tomekk> That was awesome [*Anonymous*] Shall we do it again? ReqId:[126556]
17:36:48 < botty> ReqId echo -> 126556
d
doggo
Halfop
Posts: 97
Joined: Tue Jan 05, 2010 7:53 am
Contact:

Post by doggo »

Code: Select all

[09:39pm] <<inner-b0t>  That was awesome [*Anonymous*] Shall we do it again? ReqId:[126675]
[09:39pm] <hub> -sendnzb 126675
thanks tomekk your a star :)


just one more quick question :P

how would implement a 2 sec delay for the PRIVMSG response

thanks again too it works a treat :D

edit:

would it be possible for it to ignore this line

Code: Select all

<inner-b0t>  Request Expired after 30 days ReqId:[122673]
as it responds in channel with

Code: Select all

 [12:20am] <inner-b0t> Request Expired after 30 days ReqId:[122673] [FULL 0 this.is.a.test]
[12:20am] <hub> -sendnzb 122673] [FULL 0 this.is.a.test
thanks for the help :D
User avatar
tomekk
Master
Posts: 255
Joined: Fri Nov 28, 2008 11:35 am
Location: Oswiecim / Poland
Contact:

Post by tomekk »

ignore, change:

Code: Select all

if {[regsub -all -nocase {.*ReqId:\[(.*)\].*} $arg {\1} arg]} {
to

Code: Select all

if {[regsub -all -nocase {.*again\?\s+ReqId:\[(.*)\].*} $arg {\1} arg]} {
'sleep'
http://tmml.sourceforge.net/doc/tcl/after.html

or try something with TCL timers

cheers
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Send the message after two seconds.

Code: Select all

utimer 2 [list puthelp "PRIVMSG $chan :ReqId echo -> $arg"]
Post Reply