| View previous topic :: View next topic |
| Author |
Message |
Stupidman Voice
Joined: 11 Sep 2007 Posts: 7
|
Posted: Tue Oct 09, 2007 3:10 pm Post subject: Help please I'm lost |
|
|
I have the code I want to use for the project I'm working on, but, I want it to be displayed only when the person types it in a certain channel. I dont want it in any other channel but that. I have all the code but I can't figure out how to make it like this
if (word isin channel) { putmsg $chan :Hi! } { else halt }
So if the word, word is not in "channel", dont do anything, but if it is. tell them the bot said hi.
Am I making any sense, I dont know if I make any sense? |
|
| Back to top |
|
 |
tueb Halfop
Joined: 04 Oct 2007 Posts: 76 Location: #quiz.de @ irc.gamesurge.net
|
Posted: Wed Oct 10, 2007 4:23 am Post subject: |
|
|
I'm not quite sure what you want.
Maybe this will help you:
| Code: | set urchan "#chan"
set word "word"
set msg "Hi!"
bind pub - $word my:example
proc my:example {nick uhost hand chan text} {
global urchan msg
if {$chan != $urchan} { return }
putserv "PRIVMSG $chan :$msg"
#
#place additional code here
#
} |
|
|
| Back to top |
|
 |
rosc2112 Revered One

Joined: 19 Feb 2006 Posts: 1454 Location: Northeast Pennsylvania
|
Posted: Wed Oct 10, 2007 1:06 pm Post subject: |
|
|
Here's a typical way of limiting which channels a script runs in:
| Code: |
# Channels where we allow public use:
set moviechans "#mychan #chan2 #etc"
bind pub - .movies proc:movies
bind msg - .movies proc:msgmovies
proc proc:msgmovies {nick uhost hand text} {
if {![onchan $nick]} {return}
proc:movies $nick $uhost $hand privmsg $text
return
}
proc proc:movies {nick uhost hand chan text} {
set command [lindex [split $text] 0]
if {([lsearch -exact $::moviechans $chan] == -1) && ($chan != "privmsg")} {return}
if {([lsearch -exact $::moviequiet $chan] != -1) || ($chan == "privmsg")} {set chan $nick}
# and so on
}
|
Note that using $:: is equivalent to using a global declaration. So, you can use either a line like:
global moviechans
or just use $::moviechans to refer to global variables (outside of the proc) |
|
| Back to top |
|
 |
|