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.

mode

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
a
ap
Halfop
Posts: 44
Joined: Fri Jun 09, 2006 12:20 am

mode

Post by ap »

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
User avatar
Sir_Fz
Revered One
Posts: 3793
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Count since when?
a
ap
Halfop
Posts: 44
Joined: Fri Jun 09, 2006 12:20 am

Post by ap »

Hi Sir_Fz,

When first time bot sets +i mode due to floods then it should start the count.
thank you
r
r0t3n
Owner
Posts: 507
Joined: Tue May 31, 2005 6:56 pm
Location: UK

Post by r0t3n »

Try:

Code: Select all

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
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

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
m
metroid
Owner
Posts: 771
Joined: Wed Jun 16, 2004 2:46 am

Post by metroid »

Code: Select all

# 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)
  }
}
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Chanset enabled version:

Code: Select all

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
a
ap
Halfop
Posts: 44
Joined: Fri Jun 09, 2006 12:20 am

Post by ap »

Thank you very much everyone.

sorry one last question please. if i have a dcc procedure like

Code: Select all

proc dcc:test {handle idx text } {......}
and i wanted to call this from the following codes, what would be the correct way.

Code: Select all

proc count:mode {nickname hostname handle channel mode target} {
 .......
  if {$count($channel) >= $count(max)} {
     dcc:test $handle $idx $text <---------- is this correct?
  }
}
thanks again
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Assuming you've defined the variables idx and text somewhere within your code, yes.
NML_375
User avatar
Sir_Fz
Revered One
Posts: 3793
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

for the idx, you can use [hand2idx $handle] but for text it depends on what you want "text" to contain.
a
ap
Halfop
Posts: 44
Joined: Fri Jun 09, 2006 12:20 am

Post by ap »

nml375, Sir_Fz; Thank you so much.
h
honeybee
Halfop
Posts: 80
Joined: Sun Jan 01, 2006 12:42 pm

Post by honeybee »

nml375 wrote:Chanset enabled version:

Code: Select all

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
Post Reply