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 some help with this join script

Help for those learning Tcl or writing their own scripts.
Post Reply
J
JKM
Voice
Posts: 30
Joined: Sat Dec 06, 2008 11:14 pm

Need some help with this join script

Post by JKM »

Hi there,
I started on a join script, and was wondering about how I should write the "if {ChanServ JOIN}".

Code: Select all

bind msg - ?join join_proc

proc join_proc { nick chan arg }
	if {ChanServ ison $chan} {
		putquick "PRIVMSG $nick :ChanServ ison chan!"
	} else {
		putserv "JOIN $chan"
	}
	if {ChanServ JOINS} {
		putquick "PRIVMSG $chan :ChanServ joined!"
		putserv "PART $chan"
	}
}
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Code: Select all

if {[string equal -nocase "chanserv" $nick]} {
 # $nick is ChanServ
}
J
JKM
Voice
Posts: 30
Joined: Sat Dec 06, 2008 11:14 pm

Post by JKM »

So..

Code: Select all

proc join_proc { nick chan arg }
   if {ChanServ ison $chan} {
      putquick "PRIVMSG $nick :ChanServ ison chan!"
   } else {
      putserv "JOIN $chan"
   }
   if {[string equal -nocase "chanserv" $nick]} {
      # $nick is ChanServ
      putquick "PRIVMSG $chan :ChanServ joined!"
      putserv "PART $chan"
   }
}
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

You want your bot to check if ChanServ is in the channel when the bot joins?
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

For the {Chanserv JOINS} test, use the code suggested by Sir_Fz.

For the {ChanServ ison $chan} test, use this:

Code: Select all

if {[onchan ChanServ $chan} {
Further; this will not produce the desired result:

Code: Select all

putserv "JOIN $chan"
This will only cause your eggdrop to join the channel, only to get confused and leave it instantly; use the channel add command instead.
Same goes for this:

Code: Select all

putserv "PART $chan"
Use channel remove instead.

Finally, your argument-list does not match the kind of binding you're using, msg bindings calls the proc with the following parameters, nick host handle text.
It should be something like this:

Code: Select all

proc join_proc {nick host handle text} {
Finally, I don't see chan defined anywhere whithin your proc. Were you thinking of taking whatever is written after ?join as the channel-name?
NML_375
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

The problem with using [onchan] here is that the bot won't have the chanlist generated yet when it first joins. So [onchan] will return 0 even if ChanServ is actually in the channel. One solution would be to delay the check for a few seconds...
Post Reply