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.

requestbot script (wont scan channels)

Help for those learning Tcl or writing their own scripts.
Post Reply
p
prassel
Voice
Posts: 10
Joined: Sun Apr 08, 2007 6:52 pm

requestbot script (wont scan channels)

Post by prassel »

egg will join the channel if X ops from #channel is on the master channel.
i cant get it to join a channel :/

it locks up on "foreach" as i dont get any notice from it
help? :P

this is what i've got:

Code: Select all

# set your master channel that those requesting the bot has to be in #
set masterchan "#prassel"

# set message when no matches have been announced #
set nomatch "No matches announced at this moment"

# requirements (how many ops from servicechannel in the masterchannel) #
set chanusreq 1

# message to send back when a channel does not meet the requirements to get the bot #
set nochanreq "Your channel does not meet the requirements"

# message to notice user when successfully joined #
set chanjoinmsg "Joined $reqchan"

bind msg n|m|o "requestbot" chan:check
proc chan:check {nick chan} {
	set authusers 0
	set reqchan [lindex $text 0]
	foreach nick [chanlist $reqchan] {
		if {([isop $nick $reqchan] == 1) && ([onchan $nick $masterchan] == 1)} {
			incr authusers
		}
	}
	if {$authusers < $chanusreq} {
		putserv "NOTICE $nick :$nochanreq"
	}
	elseif {$authusers >= $chanusreq} {
		channel add $reqchan
		putserv "NOTICE $nick :$chanjoinmsg"
	}
}
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

First off, the number of arguments in your proc does not match the number of arguments used when the binding triggers (see doc/tcl-commands.doc).

Secondly, the variable "text" is not defined before it is used inside the same proc.

Third, you try to use some of the variabled you've defined in globalspace (outside the proc) from within the proc, using local namespace rather than the global (either access them using the "global" command, or use absolute addressing, ie $::nochanreq instead of $nochanreq

Fourth, chanlist will only operate on channels already added to your bot, so you cannot use it in this way (there is also a slight delay from when the channel is added, until your bot has actually joined it and gathered data on who's in the channel. During this time, chanlist will return an empty list).
NML_375
Post Reply