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.

Where I did wrong?

Old posts that have not been replied to for several years.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Where I did wrong?

Post by caesar »

Hi. This is a smal part of a proc from where I can't find where is the error. It seems that he dosen't remove $nick from the list and I can't see why is doing so. Can someone please point me the mistake? Thanks.

--- Part Of The Code ---

set vchannel "#channel"
set voicelist {}

proc next:purge {nick uhost handle chan msg} {
global botnick voicelist vchannel
if {$nick == $botnick || $chan != $vchannel} { return }
set index [lsearch -exact $voicelist $nick]
set voicelist [lreplace $voicelist $index $index ]
}

--- Part Of The Code ---
User avatar
Papillon
Owner
Posts: 724
Joined: Fri Feb 15, 2002 8:00 pm
Location: *.no

Post by Papillon »

just a wild guess... but

Code: Select all

set voicelist [lreplace $voicelist $index $index ]
this is taken from the tcl-command manual:
lreplace list first last ?element element ...?
.......If no element arguments are specified, then the elements between first and last are simply deleted. If list is empty, any element arguments are added to the end of the list.

if first and last are equals, I don't see how u can delete anything between them.... I might just be stupid but that's just me ;)

U could just do a foreach loop and add every nick except the one u don't want...
Elen sila lúmenn' omentielvo
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

Papillon wrote:just a wild guess... but

Code: Select all

set voicelist [lreplace $voicelist $index $index ]
[SNIP]

if first and last are equals, I don't see how u can delete anything between them.... I might just be stupid but that's just me ;)

U could just do a foreach loop and add every nick except the one u don't want...
This is all based on how lists work, and look.

Take this example list

Code: Select all

set idx [list item1 item2 item3]
Now, index 0 in the list is "item1". If I wanted to get index 0 out of this list, i would use "lindex <list> 0". a list item, consists of the begining character,t o the end character, between the list delimiters.

Remember, lists are not strings, and ranged of text can be picked out with lists, using a single index, whereas a index with a string, picks specific caracter.

As for the script not working.

You should check that this is a proper list, created using list commands.

One other thing, your if statment may be matching everytime.

Eggdrop will use the channel name, as reported by the IRC server. This name may vary from server to server, incluing changes like mixed caps or all lowercase.

To get around this, use "[string tolower]" on both your own channel name, and the incoming channel name.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Oups, seems that I used a old version code. Here is the real one:

--- Cut ---
proc next:purge {nick uhost handle chan msg} {
global botnick next
if {$nick == $botnick || $chan != $next(chan) || [validuser [nick2hand $nick $chan]]} { return }
set index [lsearch -exact $next(list) $nick]; set next(list) [lreplace $next(list) $index $index ]}
--- Cut ---
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

The same applies in this script.

Are you sure the $next(list) variable is a list, and not a string?

Are you sure that $next(chan) is in the same case as $chan.

IE, $next(chan) might = #HellO
$chan might = #HELLo
if {HELLo == #HellO}
this does not match.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Hi. I used these two set's:

set next(chan) "#channel"
set next(list) {}

Well? :)
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Get http://www.egghelp.org/files/tcl/next1.2.tar.gz and see the rest of the code, maybe I did a mistake in other place or something like this. Thanks for the reply's.
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

Tips.

As stated in a post above, you have to watch for issues of mixed case channel names.

IE, if you set $list(chan) to "#eggdrop", but the IRC servers sends a messages with the channel name "#EGGdrop", then #eggdrop does not equal #EGGdrop.

Using somthing like

Code: Select all

if {[string tolower $next(chan)] == [string tolower $chan]} {
Will tell work.

This could be a cause why the item is not removed.

Code: Select all

if {$nick == $botnick || $chan != $next(chan) || [validuser [nick2hand $nick $chan]]} { return }
In this if, you state, if (taking the examples above) "#EGGdrop" does not equal the same as "#eggdrop", then exit this script. It does not match, so it exits.

THis is probably the most likely cuase, as the script adds entries to the list correctly.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

I see. Any other sugestion?
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

Have you tried PPSlim's suggestion yet? You've ignored it like 3 times hehe. Why don't you try that, show us your new code, and tell us the results. Also, if that doesn't fix it, chances are the problem is elsewhere in the code.

Therefore here is my suggestion. After trying PPSlim's advice, add debugging statements (putlog) to the place where you add the nick, the place that removes the nick (esp. if there is more than one place), and any place that uses or modifies the list. Have a putlog next to every return statement so that you can see where your checks are failing. Anyway, you get the idea. If you do this, it will be easy to find where your problem is.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

I'm using "if {$nick == $botnick || $chan != $next(chan) || [validuser [nick2hand $nick $chan]]} { return }" in some other procs (or a line similar to this) and I have no problem with the channel name. I personaly think that is a problem with the sign and splt proc. The only problem with this is the sign/splt proc. The rest of the procs work smoothly. I'm sorry if I have gave you the wrong impression of not reading and testing your tips/sugestions. I'll rewrite the proc for the sign and splt in 2 different procs, as right now this two are in one proc. What you think/sugest to do next?
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

re-write the script, as sugested and as you said you would do.


Once this is done, and the script is proved not to be at fault, it can be looked into more.

There may be a bug in eggdrop, but while sloppy code is being used byt he user, this can't be proved.

Once the code is cleaned up, the only option left is a bug.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Hi. I looked at the binds for the sign and splt, cos I use this two binds for the same proc (next:purge) and the proc seems to be ok. The rest of the procs that use that line with the check work smoothly and I didn't had a problem with them. I must test it again now, after I have rewrited some parts of the code, including the quit/splt part. I'm wery confused with this.. What you suggest to do next?
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

Add debugging statements.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

At the quit and splt procs?
Locked