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.

Help please I'm lost

Help for those learning Tcl or writing their own scripts.
Post Reply
S
Stupidman
Voice
Posts: 7
Joined: Tue Sep 11, 2007 7:32 pm

Help please I'm lost

Post by Stupidman »

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?
t
tueb
Halfop
Posts: 76
Joined: Thu Oct 04, 2007 6:09 am
Location: #quiz.de @ irc.gamesurge.net
Contact:

Post by tueb »

I'm not quite sure what you want.
Maybe this will help you:

Code: Select all

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
#

}
User avatar
rosc2112
Revered One
Posts: 1454
Joined: Sun Feb 19, 2006 8:36 pm
Location: Northeast Pennsylvania

Post by rosc2112 »

Here's a typical way of limiting which channels a script runs in:

Code: Select all

# 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)
Post Reply