egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

mode

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
ap
Halfop


Joined: 09 Jun 2006
Posts: 44

PostPosted: Sun Jun 17, 2007 9:58 pm    Post subject: mode Reply with quote

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
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Mon Jun 18, 2007 9:41 pm    Post subject: Reply with quote

Count since when?
_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
ap
Halfop


Joined: 09 Jun 2006
Posts: 44

PostPosted: Mon Jun 18, 2007 11:10 pm    Post subject: Reply with quote

Hi Sir_Fz,

When first time bot sets +i mode due to floods then it should start the count.
thank you
Back to top
View user's profile Send private message
r0t3n
Owner


Joined: 31 May 2005
Posts: 507
Location: UK

PostPosted: Tue Jun 19, 2007 7:07 am    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Tue Jun 19, 2007 7:19 am    Post subject: Reply with quote

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
View user's profile Send private message
metroid
Owner


Joined: 16 Jun 2004
Posts: 771

PostPosted: Tue Jun 19, 2007 12:55 pm    Post subject: Reply with quote

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
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Tue Jun 19, 2007 3:44 pm    Post subject: Reply with quote

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
View user's profile Send private message
ap
Halfop


Joined: 09 Jun 2006
Posts: 44

PostPosted: Tue Jun 19, 2007 9:17 pm    Post subject: Reply with quote

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
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Wed Jun 20, 2007 5:05 am    Post subject: Reply with quote

Assuming you've defined the variables idx and text somewhere within your code, yes.
_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Wed Jun 20, 2007 10:29 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
ap
Halfop


Joined: 09 Jun 2006
Posts: 44

PostPosted: Wed Jun 20, 2007 11:21 pm    Post subject: Reply with quote

nml375, Sir_Fz; Thank you so much.
Back to top
View user's profile Send private message
honeybee
Halfop


Joined: 01 Jan 2006
Posts: 80

PostPosted: Sun Sep 23, 2007 12:03 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber