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 for those learning Tcl or writing their own scripts.
Zorb
Voice
Posts: 22 Joined: Tue Oct 17, 2006 8:14 am
Post
by Zorb » Sat Jul 14, 2007 8:51 am
Well, the idea is when the bot is invited to a channel it joins but if the user amount in the channel is lower than 3 it will part.
I just can't think of how to get the number of people in the channel.
Thank you in advance.
scarface
Voice
Posts: 12 Joined: Mon Jul 11, 2005 3:49 pm
Post
by scarface » Sat Jul 14, 2007 9:13 am
well, its [llength [chanlist #channel]]
but since the bot joins u should do this check after recieving the nicklist on the channel (bind raw) dont remember the raw atm. if you just use a bind join proc for it, the bot havent recieved the chanlist, and it will return 1.
awyeah
Revered One
Posts: 1580 Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:
Post
by awyeah » Sat Jul 14, 2007 2:52 pm
Well you will need to use bind raw with the keyword "INVITE". You will also need an additional bind join, for the bot to check on join the channel user count and then based on that either part or stay in the channel.
Here is a basic script which can do the work for you, make changes and edit it yourself the way you would want it to work accordingly.
Code: Select all
bind raw - INVITE invite:detector
bind join - "*" check:chan:count
proc invite:detector {from keyword arg} {
channel add [string tolower [lindex [split [join $arg ""] :] 1]]
}
proc check:chan:count {nick uhost hand chan} {
if {[isbotnick $nick]} {
if {[llength [chanlist $chan]] < 3} {
channel remove $chan
}
}
}
·awyeah·
==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
r0t3n
Owner
Posts: 507 Joined: Tue May 31, 2005 6:56 pm
Location: UK
Post
by r0t3n » Sat Jul 14, 2007 3:18 pm
awyeah its best to bind on raw 315 (end of who) so then the bot would of got the list.
Code: Select all
bind raw - INVITE invite:detector
bind raw - 315 check:chan:count
proc invite:detector {from keyword arg} {
global invite
if {[validchan [string tolower [lindex [split [join $arg ""] :] 1]]]} { return }
set invite([string tolower [lindex [split [join $arg ""] :] 1]])
channel add [string tolower [lindex [split [join $arg ""] :] 1]]
}
proc check:chan:count {from keyword arg} {
global invite
if {![info exists invite([set chan [string tolower [lindex [split $arg] 1]]])]} {
unset $invite($chan)
if {[llength [chanlist $chan]] < 3} {
channel remove $chan
}
}
}
Just a few tweaks to awyeah's code.
r0t3n @ #r0t3n @ Quakenet
caesar
Mint Rubber
Posts: 3778 Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory
Post
by caesar » Sat Jul 14, 2007 5:19 pm
I see that you are using '[string tolower [lindex [split [join $arg ""] :] 1]]' 3 times. Why haven't you done the same thing like in 'if {![info exists invite([set chan [string tolower [lindex [split $arg] 1]]])]} {' ?
Once the game is over, the king and the pawn go back in the same box.
Sir_Fz
Revered One
Posts: 3794 Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:
Post
by Sir_Fz » Sun Jul 15, 2007 9:40 am
Do not apply join over a string.
awyeah
Revered One
Posts: 1580 Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:
Post
by awyeah » Mon Jul 16, 2007 3:41 am
Why shouldn't we apply join over a string? join is used in relation with strings. I don't understand this, please elaborate Sir_Fz.
Anyway Tossers, could would work, but as caesar mentioned to make it more understandable and readable easier to the eye, you can use this:
Code: Select all
bind raw - INVITE invite:detector
bind raw - 315 check:chan:count
proc invite:detector {from keyword arg} {
global invite
set chan [lindex [split [join [string tolower $arg] ""] :] 1]
if {[validchan $chan]} { return 0 }
set invite($chan) 1
channel add $chan
}
proc check:chan:count {from keyword arg} {
global invite
set chan [string tolower [lindex [split $arg] 1]]
if {[info exists invite($chan)]} {
if {[llength [chanlist $chan]] < 3} {
channel remove $chan
unset invite($chan)
} else {
unset invite($chan)
}
}
}
·awyeah·
==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
Zorb
Voice
Posts: 22 Joined: Tue Oct 17, 2006 8:14 am
Post
by Zorb » Mon Jul 16, 2007 4:40 am
Okay well, everything works well but when someone parts the channel I need it to check the users again.
So what's the bind for when someone parts the channel?
awyeah
Revered One
Posts: 1580 Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:
Post
by awyeah » Mon Jul 16, 2007 4:43 am
bind part <flags> <mask> <proc>
procname <nick> <user@host> <handle> <channel> <msg>
Description: triggered by someone leaving the channel. The mask is matched against "#channel nick!user@host" and can contain wildcards. If no part message is specified, msg will be set to "".
New Tcl procs should be declared as
proc partproc {nick uhost hand chan {msg ""}} { ... }
for compatibility.
Module: irc
Something like this:
Code: Select all
bind part - "*" check:users:on:part
proc check:users:on:part {nick uhost hand chan {text ""}} {
if {![isbotnick $nick]} {
#whatever you want to do here
}
}
·awyeah·
==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
Sir_Fz
Revered One
Posts: 3794 Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:
Post
by Sir_Fz » Mon Jul 16, 2007 6:37 am
Basically, [join] converts lists into strings. Check the
join manual page.