| View previous topic :: View next topic |
| Author |
Message |
ap Halfop
Joined: 09 Jun 2006 Posts: 44
|
Posted: Sun Jun 17, 2007 9:58 pm Post subject: mode |
|
|
Hi, i would appreciate if someone can write me a small procedure to count how many time bot has set +i mode in the channel? if count is greater than 5 then set +m mode
thank you |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
|
| Back to top |
|
 |
ap Halfop
Joined: 09 Jun 2006 Posts: 44
|
Posted: Mon Jun 18, 2007 11:10 pm Post subject: |
|
|
Hi Sir_Fz,
When first time bot sets +i mode due to floods then it should start the count.
thank you |
|
| Back to top |
|
 |
r0t3n Owner
Joined: 31 May 2005 Posts: 507 Location: UK
|
Posted: Tue Jun 19, 2007 7:07 am Post subject: |
|
|
Try:
| Code: | set count(channels) "[list #channel1 #channel2 #channel3 #etc]"
set count(max) "5"
set count(modes) "+m"
bind mode -|- "% *+i*" count:mode
proc count:mode {nickname hostname handle channel mode target} {
global count
if {[lsearch -exact $count(channels) $channel] == -1} { return }
if {![isbotnick $nickname]} { return }
if {$mode == "+i"} {
if {![info exists count($channel)]} {
set count($channel) "1"
} else {
incr count($channel) 1
}
if {$count($channel) >= $count(max)} {
pushmode $channel $count(modes)
}
}
} |
_________________ r0t3n @ #r0t3n @ Quakenet |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Tue Jun 19, 2007 7:19 am Post subject: |
|
|
Keep in mind that lsearch uses case-sensitive searches, so your list of channels would have to match whatever case is used by whomever issues the mode (in this case, bot only). Same goes for the channel-speciffic counter.
You'd probably be better off using a chanset toggle, and using something like "string tolower" when indexing your array. _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
metroid Owner
Joined: 16 Jun 2004 Posts: 771
|
Posted: Tue Jun 19, 2007 12:55 pm Post subject: |
|
|
| Code: | # only in lowercase, so #channel1 and not #ChannEl1.
set count(channels) [list #channel1 #channel2 #channel3 #etc]
set count(max) 5
set count(modes) "+m"
bind mode -|- "% *+i*" count:mode
proc count:mode {nickname hostname handle channel mode target} {
global count
if {([lsearch -exact $count(channels) [string tolower $channel]] == -1) || ![isbotnick $nickname]} { return }
if {![info exists count($channel)]} {
set count($channel) 1
} else {
incr count($channel)
}
if {$count($channel) >= $count(max)} {
pushmode $channel $count(modes)
}
} |
|
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Tue Jun 19, 2007 3:44 pm Post subject: |
|
|
Chanset enabled version:
| Code: | setudef flag countmodes
setudef int maxcountmodes
setudef str docountmodes
bind mode -|- "% *+i*" count:mode
proc count:mode {nickname hostname handle channel mode target} {
global count
if {!([channel get $channel countmodes] && [isbotnick $nickname])} { return 0 }
set channel [string tolower $channel]
if {![info exists count($channel)]} {
set count($channel) 1
} else {
incr count($channel)
}
if {$count($channel) >= [channel get $channel maxcountmodes]} {
pushmode $channel [channel get $channel docountmodes]
}
} |
_________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
ap Halfop
Joined: 09 Jun 2006 Posts: 44
|
Posted: Tue Jun 19, 2007 9:17 pm Post subject: |
|
|
Thank you very much everyone.
sorry one last question please. if i have a dcc procedure like
| Code: | | proc dcc:test {handle idx text } {......} | and i wanted to call this from the following codes, what would be the correct way.
| Code: | proc count:mode {nickname hostname handle channel mode target} {
.......
if {$count($channel) >= $count(max)} {
dcc:test $handle $idx $text <---------- is this correct?
}
} |
thanks again |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Wed Jun 20, 2007 5:05 am Post subject: |
|
|
Assuming you've defined the variables idx and text somewhere within your code, yes. _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Wed Jun 20, 2007 10:29 am Post subject: |
|
|
for the idx, you can use [hand2idx $handle] but for text it depends on what you want "text" to contain. _________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
ap Halfop
Joined: 09 Jun 2006 Posts: 44
|
Posted: Wed Jun 20, 2007 11:21 pm Post subject: |
|
|
| nml375, Sir_Fz; Thank you so much. |
|
| Back to top |
|
 |
honeybee Halfop
Joined: 01 Jan 2006 Posts: 80
|
Posted: Sun Sep 23, 2007 12:03 am Post subject: |
|
|
| nml375 wrote: | Chanset enabled version:
| Code: | setudef flag countmodes
setudef int maxcountmodes
setudef str docountmodes
bind mode -|- "% *+i*" count:mode
proc count:mode {nickname hostname handle channel mode target} {
global count
if {!([channel get $channel countmodes] && [isbotnick $nickname])} { return 0 }
set channel [string tolower $channel]
if {![info exists count($channel)]} {
set count($channel) 1
} else {
incr count($channel)
}
if {$count($channel) >= [channel get $channel maxcountmodes]} {
pushmode $channel [channel get $channel docountmodes]
}
} |
|
I dont think this script works, set up settings but still nothing happened and i was wondering if it can check max mode change in mints. ex: 3:5 |
|
| Back to top |
|
 |
|