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.

Autovoice script gets caught in loop for first channel

Old posts that have not been replied to for several years.
e
egghead
Master
Posts: 481
Joined: Mon Oct 29, 2001 8:00 pm
Contact:

Post by egghead »

Sir_Fz wrote:I would suggest another method

to creat a utimer checking if the user will get voice/op before dowing anything.
[snip]
Just curious, why would you suggest that, aside from the fun of having a lot of timers running?

NightHawk has shown that one join triggers 14 modes +v in his case. Let us replace those modes by your timers.

Now suppose a small join/part floodnet of 50 bots joins the channel. Then 50 * 14 timers are started (700).

Or for more fun: suppose that that little floodnet joins all 14 channels listed. Then 14 * 50 * 14 timers are started. Which is slightly less than 10.000 timers.
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

lol, didn't think of that.
but the reason i suggested this, is for example if a user joins the channel and service give him op, or voice (during the 4 seconds) then the bot won't do anything.

also u can make a code to *not* trigger the script on join floods or join/part floods, or u can do a killutimer if exists more than once on same nick... (but I'm not that good)
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

You're right, you did say you restarted the bot, but not everybody realizes the difference between restarting and rehashing. I was just making sure.

You probably should start over with your code. It's poorly designed right now. When a user joins the channel, you should only voice him on that channel. It doesn't make sense to voice him on all the channels in $voice_chans, because either he's only joined one of them, or he's already been voiced on the others when he joined those. And um, I'd leave out the voice_chan2 var, because it really doesn't make sense. Why is it easier to add a new channel to voice_chan2 than just voice_chans? heh

So, use lsearch to see if $chan is in $voice_chans. If it is, then send the +v for that nick on that channel only.

Also, can the bot voice himself when he joins a channel? When you first join you generally don't have ops, and thus can't voice anybody. So perhaps it would be better to use a mode bind and when the bot does get +o, then send a +v.
User avatar
Dedan
Master
Posts: 260
Joined: Wed Jul 09, 2003 10:50 pm
Location: Memphis

Post by Dedan »

knightHawk, try something like this,
maybe it will work for you.

Code: Select all

# Channels you want to auto-voice Nicks on. 
# Multiple channels seperated by spaces.
# set av-chans "#TCLhelp #TCLlovers"
set av-chans "#chan1 #chan2 #chan3 #chan4 #chan5 #chan6 #chan7 #chan8 #chan9 #chan10" 


# The Settings below should work well for you, give them a try first
# Set the Max Number of Joins here
set av-limit 3

# During the Number of Seconds here
set av-sec 3

# Set the Number of Seconds to wait before Voicing the Nick here 3
# Do not set this below 1
set av-time 2

bind join - "*" auto:voice
proc auto:voice {nick uhost handle chan} {
  global botnick av-chans av-limit av-sec av-time av-ctr av-mode
  set chan [string tolower $chan]
  if {![botisop $chan]} {
    return 0
  }
  if {![info exists av-ctr([$chan])]} {return 0}
  incr av-ctr($chan) 1
  utimer $av-sec [list av:dec $chan]
  if {$av-ctr($chan) >= $av-limit} {
    set av-mode($chan) 0
    return 0
  } else {
    set av-mode($chan) 1
    utimer $av-time [list av:voice $nick $chan]
    return 0
  }
}
proc av:voice {nick chan} {
  av-mode
  if {$av-mode($chan) == 0} {
    return 0
  }
  if {[onchan $nick $chan] && ![isvoice $nick $chan]} {
    pushmode $chan +v $nick
  } else {
    return 0
  }
}
proc av:dec {chan} {
  global av-ctr
  incr av-ctr($chan) -1
}
foreach chan [string tolower $av-chans] { 
  if {![info exists av-ctr([string tolower $chan])]} { 
    set av-ctr([string tolower $chan]) 0 
  }
  if {![info exists av-mode([string tolower $chan])]} { 
    set av-mode([string tolower $chan]) 1 
  }
}
I once was an intelligent young man, now i am old and i can not remember who i was.
K
KnightHawk
Voice
Posts: 13
Joined: Sun Jul 13, 2003 1:07 pm

Post by KnightHawk »

Sorry its been awhile since my last post. After careful review of the suggestions, and some serioous studying yet again of coding, things are working very smoothly now, bot voices it self, voices users...etc....without the loop that was there, and it has seriously helped reduce the lag issue. Had to separate it into 2 procs, but thats ok, as long as it works better and more efficiently than it was :)

Here is the coding i have at this point:

Code: Select all

bind join *|* * join_autovoice
bind join *|* * botvoice
proc join_autovoice {nick uhost hand chan} {
 global voice_chans botnick
 set chan [string tolower $chan]
 foreach i [string tolower $voice_chans] {
  if {$i == $chan && [botisop $chan]} {
   putquick "MODE $chan +v $nick"
   putlog "$nick was voiced by me on $chan"
  }
  if {$i == $chan && [botishalfop $chan]} {
   putquick "MODE $chan +v $nick"
   putlog "$nick was voiced by me on $chan"
  }
 }
}
proc botvoice {nick uhost hand chan} {
 global voice_chans botnick
 if {$nick == $botnick} {
  set chan [string tolower $chan] 
  foreach i [string tolower $voice_chans] {
   if {$i == $chan} {
    putquick "MODE $chan +v $botnick"
    putlog "I voiced myslef on $chan"
   }
  }
 }
}
Locked