| View previous topic :: View next topic |
| Author |
Message |
Zorb Voice
Joined: 17 Oct 2006 Posts: 22
|
Posted: Sat Jul 14, 2007 8:51 am Post subject: REALLY SIMPLE - I'm having a block and am tired. |
|
|
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. |
|
| Back to top |
|
 |
scarface Voice
Joined: 11 Jul 2005 Posts: 12
|
Posted: Sat Jul 14, 2007 9:13 am Post subject: |
|
|
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. |
|
| Back to top |
|
 |
r0t3n Owner
Joined: 31 May 2005 Posts: 507 Location: UK
|
|
| Back to top |
|
 |
awyeah Revered One

Joined: 26 Apr 2004 Posts: 1580 Location: Switzerland
|
Posted: Sat Jul 14, 2007 2:52 pm Post subject: |
|
|
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: |
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.
================================== |
|
| Back to top |
|
 |
r0t3n Owner
Joined: 31 May 2005 Posts: 507 Location: UK
|
Posted: Sat Jul 14, 2007 3:18 pm Post subject: |
|
|
awyeah its best to bind on raw 315 (end of who) so then the bot would of got the list.
| Code: | 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 |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Sat Jul 14, 2007 5:19 pm Post subject: |
|
|
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. |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
|
| Back to top |
|
 |
awyeah Revered One

Joined: 26 Apr 2004 Posts: 1580 Location: Switzerland
|
Posted: Mon Jul 16, 2007 3:41 am Post subject: |
|
|
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: |
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.
================================== |
|
| Back to top |
|
 |
Zorb Voice
Joined: 17 Oct 2006 Posts: 22
|
Posted: Mon Jul 16, 2007 4:40 am Post subject: |
|
|
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? |
|
| Back to top |
|
 |
awyeah Revered One

Joined: 26 Apr 2004 Posts: 1580 Location: Switzerland
|
Posted: Mon Jul 16, 2007 4:43 am Post subject: |
|
|
| Quote: |
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: |
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.
================================== |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Mon Jul 16, 2007 6:37 am Post subject: |
|
|
Basically, [join] converts lists into strings. Check the join manual page. _________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
|