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 

namespace, foreach - problem

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
caramba
Voice


Joined: 21 Feb 2009
Posts: 2

PostPosted: Sat Feb 21, 2009 1:16 pm    Post subject: namespace, foreach - problem Reply with quote

Hi everyone

simple script:
Code:
bind pub - !do do_proc

proc do_proc {unick uhost uhand uchan uarg} {
        namespace eval $unick {
                set nickname [lindex [split [namespace current] ":"] 2]

                set letters {a b c d e f g}

                foreach letter [split $letters] {
                        putquick "PRIVMSG $nickname :$letter"
                }
        }
}


We have on one channel, user1 and user2.

When user1 type !do script is writing letters, yeah that's okey.
Now, after 2 seconds user2 is typing !do too and the problem begins..

user1, pm:
Code:
a
b
c
d
e
f
g


user2, pm:
Code:

d
e
f
g
a
b
c


Can someone help with that?
How to make this to work?
I mean how to make this to "parallel"...

If i tried without "foreach", just some simple incr var 1 inside namespace, it was good.

I could make !do on first and second user and all were good, numbers were ok for both of them.
I don't know why its not working with foreach/for.

Thanks!

P.S
Sorry for my bad english.
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Sat Feb 21, 2009 1:56 pm    Post subject: Reply with quote

That's odd, very odd..

Since eggdrop operates in a non-threaded fashion, each binding will block until completed, so the second !do won't be processed until the first one is actually completed.

This would actually point a finger at the queue-system, as putquick does not send the command instantly, but places it in a queue to be send as soon as possible. However, this breaking on foreach but no other loop-constructs points in other directions.

Do you think you could add som putlog's in there, especially within the loop logging the message to be queue'd, and anything else possibly of value?
Also, could you post details on version of eggdrop and tcl?
_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
tomekk
Master


Joined: 28 Nov 2008
Posts: 255
Location: Oswiecim / Poland

PostPosted: Tue Feb 24, 2009 6:53 pm    Post subject: Reply with quote

damn, i have the same problem in many scripts.

for example, we have text file:
row
row2
row3

etc etc.

And now, we have a script with:
bind pub - !test foreach_proc

...
foreach line [file data] {
puthelp "privmsg $nick :$line"
}
...

Its working good for one person.
Problem begins when 2 or more ppl is using this command in one time.

Some problem with eggdrop queue, don't know.
I tried to do my own queue etc. but no effect (with timers, user by user).

Script is making this foreach pretty fast (whole data is landing in command queue) and after, script is going to next line when bot outputing messages and im getting mess.

user1
row
row2
row3

user2
row2
row
row3

or something

P.S
Many scripts on net have this problem. (scripts which printing many lines of data and can be used by 2 or more ppl in the same time by some command)
I think my last (and other ;/) two scripts from request too.
I mean football-table/profile scripts.

It funny cause i dont remember how long i'm programming for eggdrop, all other scripts are working ok, but this "parallel" output is horible.


Last edited by tomekk on Tue Feb 24, 2009 7:23 pm; edited 6 times in total
Back to top
View user's profile Send private message Visit poster's website
caramba
Voice


Joined: 21 Feb 2009
Posts: 2

PostPosted: Tue Feb 24, 2009 6:58 pm    Post subject: Reply with quote

Hey

I tested it on TCL 8.4.12, 8.5.5 with eggdrop 1.6.18.
The same problem on both.

Like tomekk said, it's something wrong with queue.
I don't know how to fix it.
I changed in config "max-queue-msg" no effect.
I tried puthelp/putquick/putserv - nothing.

There is no possibility to send more data (line by line) to 2 or more users in the same time?

Regards
M.

P.S
If i made putlog instead put* i got messages okey, i mean:

a
b
c
d

a
b
c
d
Back to top
View user's profile Send private message
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Tue Feb 24, 2009 8:12 pm    Post subject: Reply with quote

Have you ever thought, maybe this is related to latency?

Instead of running your tests where lag (latency) can cause messages to fall out or order. Foreach executes instantaneously as it does the putserv. All of this happens so fast, lag is certainly a factor when reading reply times spewed onto irc. Instead of using that putserv use a putlog where lag cannot come in play, and you will see lag is the culprit.
_________________
speechles' eggdrop tcl archive
Back to top
View user's profile Send private message
tomekk
Master


Joined: 28 Nov 2008
Posts: 255
Location: Oswiecim / Poland

PostPosted: Wed Feb 25, 2009 8:19 am    Post subject: Reply with quote

lag, dont think so

iim testing it on myown localhost ircd server

i found smth else, this script:
Code:
bind pub - !test test_proc

proc test_proc { nick uhost hand chan arg } {
        set blah [open "ble.txt" r]
        set all [read $blah]
        close $blah

        foreach line [split $all "\n"] {
                puthelp "PRIVMSG $nick :$line"
        }
}


ble.txt:
Code:
aaaa
bbbb
cccc
dddd
eeee
ffff
gggg
hhhh


User1 is making !test on chan, after when bot prints 1st line to user1, user2 is making !test too:

user1 output:
aaab
bbbb
cccc
ddd
eeee
ffff
gggg
hhhh

user2 output:
bbbb
cccc
ddd
eeee
ffff
gggg
hhhh
aaaa

it's messy, ok

now, if i change script:
Code:
bind pub - !test test_proc

proc test_proc { nick uhost hand chan arg } {
        set blah [open "ble.txt" r]
        set all [read $blah]
        close $blah

        foreach line [split $all "\n"] {
                puthelp "PRIVMSG $nick :$line [queuesize]" #extra [queuesize] here
        }
}


And the same situation, user1 test1, after first line, user2 !test, output:

user1:
aaaa 0
bbbb 1
cccc 2
dddd 3
eeee 4
ffff 5
gggg 6
hhhh 7
8

user2:
aaaa 8
bbbb 9
cccc 10
dddd 11
eeee 12
ffff 13
gggg 14
hhhh 15
16

now its cool, any solution? Smile
tested couple of times
Back to top
View user's profile Send private message Visit poster's website
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Wed Feb 25, 2009 1:19 pm    Post subject: Reply with quote

Could you tell me how you set these settings?
Code:
# Allow identical messages in the mode queue?
#set double-mode

# Allow identical messages in the server queue?
#set double-server

# Allow identical messages in the help queue?
#set double-help

_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
tomekk
Master


Joined: 28 Nov 2008
Posts: 255
Location: Oswiecim / Poland

PostPosted: Wed Feb 25, 2009 1:26 pm    Post subject: Reply with quote

I have it on default 0, but i tried to change it to 1, no effect.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help 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