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.

Need a lil help with this tcl script

Old posts that have not been replied to for several years.
X
XceL
Voice
Posts: 20
Joined: Wed Jan 14, 2004 8:57 pm

Need a lil help with this tcl script

Post by XceL »

ok i was searching and trying to compile me a little script, and i cant get it to work, but here is what i want, i want it to check a channel and if a certain word is said in that channel, i want the whole line that the word was in to be sent to another channel.. here is what i ended up with:

Code: Select all

set mainchan "#main"
set relaychan "#relay"
set word "keywordhere" 

bind pubm - "*" relay_pubm

proc relay_pubm {nick host handle channel args} {
  
  if {[strlwr $channel] != [strlwr $::mainchan]} { return }
    if {[lsearch -exact [string tolower $word] "keywordhere]"] != -1} {                     
      putserv "PRIVMSG $::relaychan :($channel) $nick: $args"
 }
}
thanks in advance
User avatar
arcane
Master
Posts: 280
Joined: Thu Jan 30, 2003 9:18 am
Location: Germany
Contact:

Post by arcane »

Code: Select all

set mainchan "#main" 
set relaychan "#relay" 
set word "keywordhere" 

bind pubm - "*" relay_pubm 

proc relay_pubm {nick host handle channel text} {
    if {[strlwr $channel] != [strlwr $::mainchan]} { return }
    if {[string match -nocase "*$::word*" $text] != -1} {
        putserv "PRIVMSG $::relaychan :($channel) $nick: $text"
    } 
}
should work (not tested).
aVote page back online!
Check out the most popular voting script for eggdrop bots.

Join the metal tavern!
X
XceL
Voice
Posts: 20
Joined: Wed Jan 14, 2004 8:57 pm

Post by XceL »

nope still didnt work, no matter what i typed it sent it to the relay channel..
User avatar
strikelight
Owner
Posts: 708
Joined: Mon Oct 07, 2002 10:39 am
Contact:

Post by strikelight »

That would be because string match never returns -1...

change

Code: Select all

if {[string match -nocase "*$::word*" $text] != -1} { 
to

Code: Select all

if {[string match -nocase "*$::word*" $text]} { 
X
XceL
Voice
Posts: 20
Joined: Wed Jan 14, 2004 8:57 pm

Post by XceL »

that worked, thanks :))
c
cvanmeer
Halfop
Posts: 40
Joined: Tue Dec 02, 2003 1:00 pm
Location: The Netherlands
Contact:

Post by cvanmeer »

what would you have to change in this script to respond to multiple words?
User avatar
arcane
Master
Posts: 280
Joined: Thu Jan 30, 2003 9:18 am
Location: Germany
Contact:

Post by arcane »

strikelight wrote:That would be because string match never returns -1...
oops :oops: lsearch returns -1... my fault.

to change use it for multiple words you should work with lists.
set words {"word1" "word2" "word3"}
and then:
foreach word $words {
if string match *$word* $text
}
this should give you the idea.
aVote page back online!
Check out the most popular voting script for eggdrop bots.

Join the metal tavern!
t
tweaKey

Post by tweaKey »

Useful script you got there! But is it possible to change the "mainchan" part so it instead checks all the channels the bot is in, and not just one channel? I'm kind of new to tcl, so i'm very thankful if somebody could tell me how to do this. :wink:
User avatar
Rusher2K
Halfop
Posts: 88
Joined: Fri Apr 18, 2003 10:45 am
Location: Germany
Contact:

Post by Rusher2K »

tweaKey here:

Code: Select all

set relaychan "#relay" 
set word "keywordhere" 

bind pubm - "*" relay_pubm 

proc relay_pubm {nick host handle channel text} { 
    if {[string match -nocase "*$::word*" $text] != -1} { 
        putserv "PRIVMSG $::relaychan :($channel) $nick: $text" 
    } 
}
User avatar
strikelight
Owner
Posts: 708
Joined: Mon Oct 07, 2002 10:39 am
Contact:

Post by strikelight »

Rusher2K wrote:tweaKey here:

Code: Select all

set relaychan "#relay" 
set word "keywordhere" 

bind pubm - "*" relay_pubm 

proc relay_pubm {nick host handle channel text} { 
    if {[string match -nocase "*$::word*" $text] != -1} { 
        putserv "PRIVMSG $::relaychan :($channel) $nick: $text" 
    } 
}
Heh... oy... again with the same bug as previously mentioned...
string match will NEVER EVER IN A MILLION YEARS return -1, thus making the comparison ALWAYS TRUE... heh....
User avatar
Rusher2K
Halfop
Posts: 88
Joined: Fri Apr 18, 2003 10:45 am
Location: Germany
Contact:

Post by Rusher2K »

I had only see :

Useful script you got there! But is it possible to change the "mainchan" part so it instead checks all the channels the bot is in, and not just one channel? I'm kind of new to tcl, so i'm very thankful if somebody could tell me how to do this.


Now the fixed code:

Code: Select all

set relaychan "#relay" 
set word "keywordhere" 

bind pubm - "*" relay_pubm 

proc relay_pubm {nick host handle channel text} { 
    if {[string match -nocase "*$::word*" $text] == 1} { 
        putserv "PRIVMSG $::relaychan :($channel) $nick: $text" 
    } 
}
User avatar
strikelight
Owner
Posts: 708
Joined: Mon Oct 07, 2002 10:39 am
Contact:

Post by strikelight »

Rusher2K wrote:I had only see :

Useful script you got there! But is it possible to change the "mainchan" part so it instead checks all the channels the bot is in, and not just one channel? I'm kind of new to tcl, so i'm very thankful if somebody could tell me how to do this.
Then maybe you should read an entire thread before replying.... Just a thought.
Rusher2K wrote: Now the fixed code:

Code: Select all

set relaychan "#relay" 
set word "keywordhere" 

bind pubm - "*" relay_pubm 

proc relay_pubm {nick host handle channel text} { 
    if {[string match -nocase "*$::word*" $text] == 1} { 
        putserv "PRIVMSG $::relaychan :($channel) $nick: $text" 
    } 
}
As previously mentioned with the original fix....
you can make it just:

Code: Select all

if {[string match -nocase "*$::word*" $text]} {
User avatar
Rusher2K
Halfop
Posts: 88
Joined: Fri Apr 18, 2003 10:45 am
Location: Germany
Contact:

Post by Rusher2K »

strikelight good idea :)
In future I read an entire thread before replying.
:D
User avatar
arcane
Master
Posts: 280
Joined: Thu Jan 30, 2003 9:18 am
Location: Germany
Contact:

Post by arcane »

strikelight wrote: string match will NEVER EVER IN A MILLION YEARS return -1
heh... wanna bet? :mrgreen:

Code: Select all

proc string {args} {
	return -1
}

edit: naaah *donk* Image loaded this script for testing and now i just wondered why my scripts were producing one error after another...
/me slaps himself and goes to bed... :oops:
aVote page back online!
Check out the most popular voting script for eggdrop bots.

Join the metal tavern!
t
tweaKey

Post by tweaKey »

Thanks guys! But one more thing :mrgreen:
Is it possible to "blacklist" one channel, so the bot does not check just that channel, but all the other channels the bot is in?
Locked