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.
K
KnightHawk
Voice
Posts: 13
Joined: Sun Jul 13, 2003 1:07 pm

Autovoice script gets caught in loop for first channel

Post by KnightHawk »

Basically, the script is supposed to voice every person that joins the chan, and the purpose to the variables of voice_chan1 or 2, is so i can add or remove a chan on a moments notice.
Problems is the script will try and voice approx 15 times , for the first channel only, and only when the bot has restarted. Which ends up lagging the bot due to the following errors:

[12:23] msg already queued. skipping: MODE #Hawksrealm +v Talon
[12:23] msg already queued. skipping: MODE #Hawksrealm +v Talon
[12:23] msg already queued. skipping: MODE #Hawksrealm +v Talon
(you get the picture)

Once it has finished this loop, all is well.
If i were to switch the first chan in the list , same problem happens only in a diff chan.

Here is the code:
set voice_chans1 "#chan1 #chan2 #chan3 #chan4 #chan5 #chan6"
set voice_chans2 "#chan7 #chan8 #chan9 #chan10"

bind join *|* * join_autovoice

proc join_autovoice {nick host hand chan} {
global voice_chans1 voice_chans2
foreach chan $voice_chans1 {
putquick "MODE $chan +v $nick"
}
foreach chan $voice_chans2 {
putquick "MODE $chan +v $nick"
}
}
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Split the list before you use the foreach. I mean, use:

Code: Select all

foreach chan [split $voice_chans1] { 
Another simple and effective solution for this *list* of channels is to make a user defined channel flag (use: "setudef flag something" and replace something with something that suits you better) and check if the channel has the flag (use: "[channel get $chan something]" and don't forget to replace something wil what flag you've set) and voice the user.
Once the game is over, the king and the pawn go back in the same box.
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

How many times did you .rehash your bot? Every time you do it, the script is reloaded and will voice the person another time. Try .restart and see if the problem still exists. Also, you should make sure the user is *on* those channels before you send the mode hehe. (Hint: use the "onchan" command.)
K
KnightHawk
Voice
Posts: 13
Joined: Sun Jul 13, 2003 1:07 pm

Post by KnightHawk »

caesar wrote:Split the list before you use the foreach. I mean, use:

Code: Select all

foreach chan [split $voice_chans1] { 
This had no affect whatsoever . As far as the other option you mentioned, i am not sure i understanding correctly
Last edited by KnightHawk on Sun Jul 13, 2003 4:00 pm, edited 1 time in total.
K
KnightHawk
Voice
Posts: 13
Joined: Sun Jul 13, 2003 1:07 pm

Post by KnightHawk »

stdragon wrote:How many times did you .rehash your bot? Every time you do it, the script is reloaded and will voice the person another time. Try .restart and see if the problem still exists. Also, you should make sure the user is *on* those channels before you send the mode hehe. (Hint: use the "onchan" command.)
Please re-read my original post. This problem only happens when the bot is started, restarted. and yes, The user is on THAT channel. As i said, it only happens to the first channel in the list of voice_chans1., and only after the bot is restarted. Rehash doesnt cause the problem. i can rehash all day long without any probs
e
egghead
Master
Posts: 481
Joined: Mon Oct 29, 2001 8:00 pm
Contact:

Post by egghead »

KnightHawk wrote:
stdragon wrote:How many times did you .rehash your bot? Every time you do it, the script is reloaded and will voice the person another time. Try .restart and see if the problem still exists. Also, you should make sure the user is *on* those channels before you send the mode hehe. (Hint: use the "onchan" command.)
Please re-read my original post. This problem only happens when the bot is started, restarted. and yes, The user is on THAT channel. As i said, it only happens to the first channel in the list of voice_chans1., and only after the bot is restarted. Rehash doesnt cause the problem. i can rehash all day long without any probs
Ok, here is what I did.

step 1: load the below code on my bot:

Code: Select all

set voice_chans1 "#chan1 #chan2 #chan3" 
set voice_chans2 "#chan1 #chan2 #chan3" 

bind join *|* * join_autovoice 

proc join_autovoice {nick host hand chan} { 
   global voice_chans1 voice_chans2 
   foreach chan $voice_chans1 { 
      putlog "Putquick mode +v for $nick on $chan"
   } 
   foreach chan $voice_chans2 { 
      putlog "Putquick mode +v for $nick on $chan"
   } 
}
Step 2: I joined the partyline of the bot.

Step 3: I typed .restart and observed the messages on the partyline.

Step 4. The bot reconnects and joins ONE channel (!) and putlogs the following lines:
[16:28] Putquick mode +v for eggheadbot on #chan1
[16:28] Putquick mode +v for eggheadbot on #chan2
[16:28] Putquick mode +v for eggheadbot on #chan3
[16:28] Putquick mode +v for eggheadbot on #chan1
[16:28] Putquick mode +v for eggheadbot on #chan2
[16:28] Putquick mode +v for eggheadbot on #chan3
This is exactly what one would expect from your code: the bot joins the channel itself and sends out a +v for itself on *EACH* of the channels defined in the variables voice_chans1 and voice_chans2. (note that my bot is only on *ONE* active channel, all other channels are set +inactive).

If the bot had 2 active channels and the bot joins them on a .restart, you would see the above 2 times i.e. 2 * 6 = 12 modes +v being pushed out. Because the bind join is triggered twice.

So, if your bot is on 10 channels, and all those 10 channels are also defined in the voice_chans1 variable, there will be 10 * 10 = 100 "mode +v" sent out. Because the bind join would be triggered 10 times, each trigger pushing out 10 +v's.

What your script is doing, is if a user joins one channel #chan1, it will send out a mode +v for *all* the channels defined in the voice_chans1 and voice_chans 2 variable.

It seems what you need is removing those loops. A bind join is for 1 channel only, so you need to send out one +v for that channel.
So, if a bind join is triggered you check if the chan is in the list of voice_chans1 and voice_chans2. The suggestion of caeser to use a user defined flag is even better.

Besides that you need to implement a couple of checks (as indicated previously), like: is the bot on the channel, does the nick to be voiced already have voice or ops, has the bot ops.

If you really want to have those loops in there, then the above tests will avoid the bot sending out so many +v's. Because upon the bot joining, a [botisop] will fail.
K
KnightHawk
Voice
Posts: 13
Joined: Sun Jul 13, 2003 1:07 pm

Post by KnightHawk »

ok, Thank you for actually loading the script and trying it. Perhaps i should correct something here.
Egghead wrote: "This is exactly what one would expect from your code: the bot joins the channel itself and sends out a +v for itself on *EACH* channel."
Correct, that is what i expect to happen, and i like it that way :0)
Egghead wrote:
So, if your bot is on 10 channels, and all those 10 channels are also defined in the voice_chans1 variable, there will be 10 * 10 = 100 "mode +v" sent out.
Yes, that is what a person would expect to happen, but is not the case on mine. If the bot resides on either 2 chans or 6, it still produces exatcly 17 (i recounted) messages. The messages are always for the same channel, which is the first channel listed in the voice_chans1 list, regardless of the name of that chan.
Egghead wrote:
A bind join is for 1 channel only, so you need to send out one +v for that channel.
I was under the impression that bind *|* would tell it to bind to all channels
Egghead wrote:
Besides that you need to implement a couple of checks (as indicated previously), like: is the bot on the channel, does the nick to be voiced already have voice, has the bot ops.
I agree, i do need those, as it would probably solve the problem, but, i dont know exactly how to go about it. I do appreciate the suggestions on the fact the checks are needed, but the method of actually creating those checks as suggested above is what i dont understand.
K
KnightHawk
Voice
Posts: 13
Joined: Sun Jul 13, 2003 1:07 pm

Post by KnightHawk »

I should also clarify the fact that the bots name is Talon. The loop is indeed happening when the bot trys to voice it self, not when a norm users joins the chan. If i restart ( not rehash) the bot, it only trys to voice itself, it doesnt try and voice people that already have one ( thanks god).
e
egghead
Master
Posts: 481
Joined: Mon Oct 29, 2001 8:00 pm
Contact:

Post by egghead »

KnightHawk wrote:
Egghead wrote:
So, if your bot is on 10 channels, and all those 10 channels are also defined in the voice_chans1 variable, there will be 10 * 10 = 100 "mode +v" sent out.


Yes, that is what a person would expect to happen, but is not the case on mine. If the bot resides on either 2 chans or 6, it still produces exatcly 17 (i recounted) messages. The messages are always for the same channel, which is the first channel listed in the voice_chans1 list, regardless of the name of that chan.
Can't confirm that. I tried it with my bot on 3 active channels. What eggdrop version are you running on what OS?
KnightHawk wrote:
Egghead wrote:
A bind join is for 1 channel only, so you need to send out one +v for that channel.


I was under the impression that bind *|* would tell it to bind to all channels
Actually the binding you created is valid for all channels. So for any channel the bot monitors, a user joining that channel will trigger that binding.

BUT: it triggers them on a channel by channel basis. So, if a user joins 10 channels all monitored by your bot, that binding will be triggered 10 times. not one time.
KnightHawk wrote:
Egghead wrote:
Besides that you need to implement a couple of checks (as indicated previously), like: is the bot on the channel, does the nick to be voiced already have voice, has the bot ops.


I agree, i do need those, as it would probably solve the problem, but, i dont know exactly how to go about it. I do appreciate the suggestions on the fact the checks are needed, but the method of actually creating those checks as suggested above is what i dont understand.
insert in your code in the appropriate place(s):

Code: Select all

if { ![botisop $chan] } { continue }
if { [isvoice $nick $chan] } { continue }
if { [isop $nick $chan] } { continue }
e
egghead
Master
Posts: 481
Joined: Mon Oct 29, 2001 8:00 pm
Contact:

Post by egghead »

KnightHawk wrote: Yes, that is what a person would expect to happen, but is not the case on mine. If the bot resides on either 2 chans or 6, it still produces exatcly 17 (i recounted) messages. The messages are always for the same channel, which is the first channel listed in the voice_chans1 list, regardless of the name of that chan.
Using putlogs you should be able to see what the bot does:

Code: Select all

set voice_chans1 "#chan1 #chan2 #chan3" 
set voice_chans2 "#chan4 #chan5 #chan6" 

bind join *|* * join_autovoice 

proc join_autovoice {nick host hand chan} {
   global voice_chans1 voice_chans2 
   putlog "Autovoice triggered by $nick joining $chan"
   putlog "Entering loop 1 for $voice_chans1"
   foreach chan $voice_chans1 { 
      putlog "Putquick mode +v for $nick on $chan" 
   } 
   putlog "Entering loop 2 for $voice_chans2"
   foreach chan $voice_chans2 { 
      putlog "Putquick mode +v for $nick on $chan" 
   } 
}
K
KnightHawk
Voice
Posts: 13
Joined: Sun Jul 13, 2003 1:07 pm

Post by KnightHawk »

Ok, tell ya what, in best interest of saving everyones time and headaches , if someone can suggest the proper coding, by all means do so. I am willing to remove the entire script and start from scratch. Bassically, all i want it do is auto voice every user that joins certain chans, including the bot itself, and have the ability to easily add and remove the chans that the auotvoice happens on. I nt eh mean time, i will try the suggestion from egghelp on using the putlogs. Will get back to ya shortly with the results
e
egghead
Master
Posts: 481
Joined: Mon Oct 29, 2001 8:00 pm
Contact:

Post by egghead »

KnightHawk wrote:Ok, tell ya what, in best interest of saving everyones time and headaches , if someone can suggest the proper coding, by all means do so. I am willing to remove the entire script and start from scratch. Bassically, all i want it do is auto voice every user that joins certain chans, including the bot itself, and have the ability to easily add and remove the chans that the auotvoice happens on. I nt eh mean time, i will try the suggestion from egghelp on using the putlogs. Will get back to ya shortly with the results
KnightHawk, either:

- you come here to ask someone to write a script for you (in which case I would have ignored your posting right away)

or

- you start writing your own code and come to this forum when you have some problems debugging your code.

But you deciced, halfway to switch from the second to the first and subsequently indeed wasted my time.

If you give up that easily on your script, it is unlikely you will get beyond the point of copying and pasting other people's snippets of Tcl into a text file and put your own name on top of it.

Do hope you will write your own script.
Last edited by egghead on Sun Jul 13, 2003 6:00 pm, edited 1 time in total.
K
KnightHawk
Voice
Posts: 13
Joined: Sun Jul 13, 2003 1:07 pm

Post by KnightHawk »

KnightHawk, either:

- you come here to ask someone to write a script for you (in which case I would have ignored your posting right away)

or

- you start writing your own code and come to this forum when you have some problems debugging your code.

But you deciced, halfway to switch from the second to the first and subsequently indeed wasted my time.[/quote]

My apolgies sir, my intention is not to waste anyones time and efforts, am just trying to make it as easy as possible on people. And no, i have nothave decided to swiutch from anything to anything, i am indeed following your suggestions on using the putlogs ,,,,which is indeed helping, and i am very appreciative for.
K
KnightHawk
Voice
Posts: 13
Joined: Sun Jul 13, 2003 1:07 pm

Post by KnightHawk »

egghead wrote:
KnightHawk wrote:Ok, tell ya what, in best interest of saving everyones time and headaches , if someone can suggest the proper coding, by all means do so. I am willing to remove the entire script and start from scratch. Bassically, all i want it do is auto voice every user that joins certain chans, including the bot itself, and have the ability to easily add and remove the chans that the auotvoice happens on. I nt eh mean time, i will try the suggestion from egghelp on using the putlogs. Will get back to ya shortly with the results
KnightHawk, either:

- you come here to ask someone to write a script for you (in which case I would have ignored your posting right away)

or

- you start writing your own code and come to this forum when you have some problems debugging your code.

But you deciced, halfway to switch from the second to the first and subsequently indeed wasted my time.
My apologies, i didnt mean to waste anyone time, merely save it for your/their benefits. I have been troubleshooting this for a few months myself, so it isnt going to hurt me personally to try a few more days.
I mean after all, if the code i wrote is *that* screwed up, why spend more days trying to fix something that may not be fixable. Why not just start from scratch., thats all i was trying to get at :)
I am indeed trying the suggestions you mentioned, and the putlogs do indeed help. I do better undertand now what u were saying regarding the
bind happening for 10 diff times.. Results below:
16:53 <Talon> [16:54] Autovoice triggered by KH-shower joining #HawksRealm
16:53 <Talon> [16:54] Entering loop 1 for #Hawksrealm #RealmRadio #DevCentral #Moonlight^Stroll #Lobby
16:53 <Talon> [16:54] Putquick mode +v for KH-shower on #Hawksrealm
16:53 <Talon> [16:54] Putquick mode +v for KH-shower on #RealmRadio
16:53 <Talon> [16:54] Putquick mode +v for KH-shower on #DevCentral
16:53 <Talon> [16:54] Putquick mode +v for KH-shower on #Moonlight^Stroll
16:53 <Talon> [16:54] Putquick mode +v for KH-shower on #Lobby
16:53 <Talon> [16:54] Entering loop 2 for #obscuredevotion #SystemSolutions #darkrift #blackcat #retroramma #riverfront #angelfalls #talelake #crimsontavern
16:53 <Talon> [16:54] Putquick mode +v for KH-shower on #obscuredevotion
16:53 <Talon> [16:54] Putquick mode +v for KH-shower on #SystemSolutions
16:53 <Talon> [16:54] Putquick mode +v for KH-shower on #darkrift
16:53 <Talon> [16:54] Putquick mode +v for KH-shower on #blackcat
16:53 <Talon> [16:54] Putquick mode +v for KH-shower on #retroramma
16:53 <Talon> [16:54] Putquick mode +v for KH-shower on #riverfront
16:53 <Talon> [16:54] Putquick mode +v for KH-shower on #angelfalls
16:53 <Talon> [16:54] Putquick mode +v for KH-shower on #talelake
16:53 <Talon> [16:54] Putquick mode +v for KH-shower on #crimsontavern

The above happened just as a result of me cycling 1 channel.

So following that methodology, i restarted the bot, and here is what i got:
17:02 <Talon> [17:03] Entering loop 1 for #Hawksrealm #RealmRadio #DevCentral #Moonlight^Stroll #Lobby
17:02 <Talon> [17:03] msg already queued. skipping: MODE #Hawksrealm +v Talon
17:02 <Talon> [17:03] Putquick mode +v for Talon on #Hawksrealm
17:02 <Talon> [17:03] Putquick mode +v for Talon on #RealmRadio
17:02 <Talon> [17:03] Putquick mode +v for Talon on #DevCentral
17:02 <Talon> [17:03] Putquick mode +v for Talon on #Moonlight^Stroll
17:02 <Talon> [17:03] Putquick mode +v for Talon on #Lobby
17:02 <Talon> [17:03] Entering loop 2 for #obscuredevotion #SystemSolutions #darkrift #blackcat #retroramma #riverfront #angelfalls #talelake #crimsontavern
17:02 <Talon> [17:03] Putquick mode +v for Talon on #obscuredevotion
17:02 <Talon> [17:03] Putquick mode +v for Talon on #SystemSolutions
17:02 <Talon> [17:03] Putquick mode +v for Talon on #darkrift
17:02 <Talon> [17:03] Putquick mode +v for Talon on #blackcat
17:02 <Talon> [17:03] Putquick mode +v for Talon on #retroramma
17:02 <Talon> [17:03] Putquick mode +v for Talon on #riverfront
17:02 <Talon> [17:03] Putquick mode +v for Talon on #angelfalls
17:02 <Talon> [17:03] Putquick mode +v for Talon on #talelake
17:02 <Talon> [17:03] Putquick mode +v for Talon on #crimsontavern
( approximately 10 or more times).....so i can definately see how the lag is being created, although now there is 1 interesting twist, i dont get the msg already queued repated anymore, which is totally unexpected.
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

I would suggest another method

to creat a utimer checking if the user will get voice/op before dowing anything.

like for example:

bind join * * join_autovoice

proc join_autovoice {nick host hand chan} {
global voice_chans1 voice_chans2
foreach chan $voice_chans1 {
utimer 4 "do:voice"
}
foreach chan $voice_chans2 {
utimer 4 "do:voice"
}
}
then creat a proc (do:voice) which will have if isvoice $nick and isop $nick return
and if isbot $nick return..... before voicing the user.
Locked