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.

.next

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

Post by caesar »

set voicelist ""

bind join - * join:add

proc join-add {nick uhost handle channel} {
global botnick voicelist
if {$nick == $botnick} { return }
if {([isop $nick $channel] || [isvoice $nick $channel])} { return }
if {([matchattr $handle m] || [matchattr $handle n] || [matchattr $handle o])} { return }
set voicelist "$voicelist $nick"
}

bind part - * part:del

proc part:del {nick uhost handle channelnel msg} {
global botnick voicelist
if {$nick == $botnick} { return }
if {([matchattr $handle m] || [matchattr $handle n] || [matchattr $handle o])} { return }
regsub -all "$nick" $voicelist "" voicelist
}

bind kick - * kick:del

proc kick:del {nick uhost handle channel victim reason} {
global botnick voicelist
if {$victim == $botnick} { return }
if {([isop $victim $channel] || [isvoice $victim $channel])} { return }
if {([matchattr $handle m] || [matchattr $handle n] || [matchattr $handle o])} { return }
regsub -all "$victim" $voicelist "" voicelist
}

bind nick - * nick:chg

proc nick:chg {nick uhost handle channelnel newnick} {
global botnick voicelist
if {$nick == $botnick} { return }
if {([isop $nick $channel] || [isvoice $nick $channel])} { return }
if {([matchattr $handle m] || [matchattr $handle n] || [matchattr $handle o])} { return }
regsub -all "$nick" $voicelist "" voicelist
set voicelist "$voicelist $newnick"
}

bind sign - * quit:del

proc quit:del {nick uhost handle channel reason} {
global botnick voicelist
if {$nick == $botnick} { return }
if {([isop $nick $channel] || [isvoice $nick $channel])} { return }
if {([matchattr $handle m] || [matchattr $handle n] || [matchattr $handle o])} { return }
regsub -all "$nick" $voicelist "" voicelist
}

bind pub n .next next:voice

proc next:voice {nick uhost handle channel arg} {
global voicelist
set who [lindex $voicelist 0]
if {$voicelist == "" } {
putserv "NOTICE $nick :Voice voicelist is empty."
return 1 }
if {[botisop $channel]} {
putserv "MODE $channel +v $who"
set voicelist [lrange $voicelist 1 end]
return 1 }
putserv "NOTICE $nick :I'm not oped on $channel. ~:o("
}

putlog ".next.. is loaded :smile:"

Here is my code.. any sugestions, bugs or something? :smile:
e
egghead
Master
Posts: 481
Joined: Mon Oct 29, 2001 8:00 pm
Contact:

Post by egghead »

Caesar, there are some minor points and suggestions... (which I'll address not all here)... but you asked for another dirty dozen :smile:

1.

Code: Select all

set voicelist ""
... in the script you treat the voicelist as a string. My advice is to call it a voiceLIST (like you did) and to make it a LIST!

2.

Code: Select all

proc join-add {nick uhost handle channel} { 
[snip]
if {([isop $nick $channel] || [isvoice $nick $channel])} { return }
If a nick joins a channel the join-add binding is directly triggered... this nick will not have ops/voice. There is no reason to check for it...

3.

Code: Select all

if {([matchattr $handle m] || [matchattr $handle n] || [matchattr $handle o])} { return } 
Although you may have your reasons to check for userflags, I would advise against this check. Only check if people have an @/+v at the moment you punch ".next".

4.

Code: Select all

set voicelist "$voicelist $nick"
This lacks multi channel support... and if you are going to treat "voicelist" as a list (like you should :smile: ).. use [lappend]...

5.

Code: Select all

bind part - * part:del 
proc part:del {nick uhost handle channelnel msg} {
[snip] 
if {([matchattr $handle m] || [matchattr $handle n] || [matchattr $handle o])} { return } 
Why this test? :???: Don't check for flags, just check if the nick is in the list and remove him/her from that list...
Suppose someone without a flag joins the channel: the nick is added to the list. Then this nick obtains the +o flag and leaves the channel. Following your code, this nick will then not be removed from the voicelist.

6.

Code: Select all

regsub -all "$nick" $voicelist "" voicelist
This is a bit dangerous. Run the following code on your shell using tcl (not on eggdrop) and try to understand what happened:

Code: Select all

set string {foo foobar barfoo bar}
regsub -all "foo" $string "" nofoo
regsub -all "bar" $string "" nobar
puts $nofoo
puts $nobar
If you are going to treat "voicelist" as a list (like you will soon :wink: ) you can use an [lsearch -exact] to search for a nick in the voicelist and remove it using [lreplace]

7.

Code: Select all

proc kick:del {nick uhost handle channel victim reason} {
[snip]
if {([isop $victim $channel] || [isvoice $victim $channel])}
Why these checks? if the victim had an op, he is not on the voicelist anymore?
Remove all the checks. Just search the voicelist and if the nick is in there, remove it.

8. Like explained earlier the script should also check for SPLT'ed and REJN'ing nicks in case of netsplits, or add a check to see if the user is on the channel in the next:voice procedure.

9.

Code: Select all

proc next:voice {nick uhost handle channel arg} { 
global voicelist 
set who [lindex $voicelist 0] 
if {$voicelist == "" } { 
putserv "NOTICE $nick :Voice voicelist is empty." 
return 1 } 
if {[botisop $channel]} { 
putserv "MODE $channel +v $who" 
set voicelist [lrange $voicelist 1 end] 
return 1 } 
putserv "NOTICE $nick :I'm not oped on $channel. ~:o(" 
}
At this point it may be more advantageous to [foreach] the voicelist upon a .next command, testing every nick in the list for (not) having @/+v. Once a nick is voiced [break] out of the [foreach] loop.

10.

Code: Select all

bind nick - * nick:chg 
proc nick:chg {nick uhost handle channelnel newnick} {
[snip]
regsub -all "$nick" $voicelist "" voicelist 
set voicelist "$voicelist $newnick"
This is not fair! The idea was that the order of the voicelist reflects the order of joining. Here you strip out a nick upon a nickchange and add the newnick at the end of the voicelist.
Note that regsub can do REPLACEments, like [lreplace] can if your voicelist were a list.

11. If you look at the voicelist bookkeeping, there are 3 actions: add a user, rename a user and purge a user. It may be advantages to write 3 small procs that are called by the JOIN/PART/SIGN etc...

12. you may want to add a purge action if a user gets a +v/+o from someone else. The reason is that you intended to only serve a "fresh" voice once. So if a nick gets a +v followed by a -v from someone else, they shouldn't get a voice from your script anymore: such nick should be removed from your voicelist.

Hope these suggestions help...

<font size=-1>[ This Message was edited by: egghead on 2002-03-18 17:51 ]</font>
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

1) I renamed from "voicelist" to "list".
2) Removed the check:
if {([isop $nick $channel] || [isvoice $nick $channel])} { return }
3) I put that check to not make the list to get bigger with the users that have access on it.
4) Well this is only for 1 channel. I got to find a way to separate this from other channels that the bot is in.
Tell me more about the "[lappend]" please.
5) I removed that check and about your "suppose" well the chances this to happen are about 1% or something.
6) Thanks for the tip. I'll keep it in my mind. The "list" is a list of nicks that will get a voice one by one folowing
".next" proces. Give me some tips about "[lsearch -exact]" and "[lreplace]" commands.
7) I removed the checks. I thing I don't need that check in there, just remove it from the list if exist else do nothing.
:cool: Ups. I forgot about the "split" and "rejoin". Got to do this part two.
9) Hmm.. I din't think about using the "[foreach]". Nice trick. Well I'll give it a try but I'm not so well informed about
if and the "break" part. Any sugestions?
10) Hahaha.. "This is not fair!". Are we playng a game or something? Just kidding. If he changes his nick while is in "channel"
then bad luck. One of the rules says not to change your nick wile in the "channel" so I think he deserves this punishment. Kidding again. :smile:
11) Well you are right. I think I'll shrink my procs, I'll make them smaller. Just kidding.
12) Hmm.. this wont happen cos no one is allowed to @ or + in the channel, except this eggy that runs the ".next" script.
I'll add this two in any case, to be there. The devoice part I think is useful, in case a "fresh" voiced nick
is away or he/she dose not deserve to have a voice in the "channel" and/or to be helped.

Yap, all your suggestions helped me. Thanks mate!
e
egghead
Master
Posts: 481
Joined: Mon Oct 29, 2001 8:00 pm
Contact:

Post by egghead »

Hiya Caesar,
4) Well this is only for 1 channel. I got to find a way to separate this from other channels that the bot is in.
Your way to go could be arrays: voicelist(#chan1), voicelist(#chan2) etc.. where each of them is a list of nicks to be considered for voicing on the channel array name.
Tell me more about the "[lappend]" please.
If you understand the concept of a list, [lappend] is the way to append an element to a list. Read up on:
http://www.scriptics.com/man/tcl8.4/TclCmd/contents.htm
5) I removed that check and about your "suppose" well the chances this to happen are about 1% or something.
Even that tiny 1 % you should catch with your script :smile:
Give me some tips about "[lsearch -exact]" and "[lreplace]" commands.
In your case, you have 3 types of userlist manipulations: add, purge and replace.
Example of add:
set voicelist($chan) [lappend voicelist($chan) $nick]

The purge and replace can be done by first searching the list for the nick:
set index [lsearch -exact $voicelist($chan) $nick]
and then purge:
set voicelist($chan) [lreplace $voicelist($chan) $index $index ]
or replace:
set voicelist($chan) [lreplace $voicelist($chan) $index $index $newnick]
9) Hmm.. I din't think about using the "[foreach]". Nice trick. Well I'll give it a try but I'm not so well informed about
if and the "break" part. Any sugestions?
The [break] out of the [foreach] loop comes as soon as you have voiced a nick. How did you fare on this one?
12) Hmm.. this wont happen cos no one is allowed to @ or + in the channel, except this eggy that runs the ".next" script.
I'll add this two in any case, to be there. The devoice part I think is useful, in case a "fresh" voiced nick
is away or he/she dose not deserve to have a voice in the "channel" and/or to be helped.
Well, you may reconsider it in case you want to make your script available (and usefull) for others.
P
Petersen
Owner
Posts: 685
Joined: Thu Sep 27, 2001 8:00 pm
Location: Blackpool, UK

Post by Petersen »

5) I removed that check and about your "suppose" well the chances this to happen are about 1% or something.
If I wrote code at work with that faliure rate, I'd be instantly fired :razz:
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Heya! I'll start modify imediatly the things you said and I'll say if I'll have problems or I don't understand something. This as I did want at the begining was for my personal use and for other's that want it like it is, or will be. I'll leave that 12 alone cos I want to make it avaliable to others to. :eek:) Thanks again for the tips!
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

1) What variables should I use for procs: add, purge and replace ? Something like "proc next:something {nick chan} {" ?
I'm asking cos I only use $nick and $chan..
2) Regarding that 1% chances to that thing happen.. I was thinking to make a command, something like
.skip, to search for the nick in the voicelist and purge it if it's there.
An other ideea is to make an .add (or something like this) that will add the $nick in a list (or better make an
user or add his host to a user) that dose not deserves voice in channel. This is usefull if that $nick is
breaking rules or something like this. I'll think about this later if I'll do this or not. Right now this 2 are not
so importnant. I'll leave the behind, at the end or something..
3) "foreach voicenick $voicelist($chan)" or how to do this? I'm not so shure about this [foreach], cos I'm a newbie
with this. :smile:
4) What is the diference betwen a PART and a SPLT? SPLT and SIGN? JOIN and REJN?

### Check ###
# (1) if $nick is a user and he dosen't have +d flag (or something like this) => return
# (2) if $nick is oped or is voiced in the channel => return

# add
proc next:add {nick chan} {
global botnick voicelist
if {$nick == $botnick} { return }
set voicelist($chan) [lappend voicelist($chan) $nick]
}

Is this next:add ok? Thanks for the add, purge and replace parts. :smile:
e
egghead
Master
Posts: 481
Joined: Mon Oct 29, 2001 8:00 pm
Contact:

Post by egghead »

On 2002-04-09 12:03, caesar wrote:
1) What variables should I use for procs: add, purge and replace ? Something like "proc next:something {nick chan} {" ?
I'm asking cos I only use $nick and $chan..
You will pass those variables to a proc that are needed by the proc. Your example of next:add (below) is a good start. Bind procs to the JOIN and REJN, and let these procs call your next:add procedure. Keep going and keep testing :razz:
2) Regarding that 1% chances to that thing happen.. I was thinking to make a command, something like
.skip, to search for the nick in the voicelist and purge it if it's there.
An other ideea is to make an .add (or something like this) that will add the $nick in a list (or better make an
user or add his host to a user) that dose not deserves voice in channel. This is usefull if that $nick is
breaking rules or something like this. I'll think about this later if I'll do this or not. Right now this 2 are not
so importnant. I'll leave the behind, at the end or something..
Once you have something going, you can indeed add many features such as .skip and .add. Once you have the next:add, next:change and next:purge, this will be an easy addition :grin:
3) "foreach voicenick $voicelist($chan)" or how to do this? I'm not so shure about this [foreach], cos I'm a newbie
with this. :smile:
Documents like http://www.scriptics.com/doc/ will help you, as well as the many scripts available for eggdrop.
4) What is the diference betwen a PART and a SPLT? SPLT and SIGN? JOIN and REJN?
Also a good document is tcl-commands.doc which comes for free with the eggdrop tarball. Read the part "COMMAND EXTENSION".
### Check ###
# (1) if $nick is a user and he dosen't have +d flag (or something like this) => return
# (2) if $nick is oped or is voiced in the channel => return

# add
proc next:add {nick chan} {
global botnick voicelist
if {$nick == $botnick} { return }
set voicelist($chan) [lappend voicelist($chan) $nick]
}

Is this next:add ok? Thanks for the add, purge and replace parts. :smile:
The checks you indicate (+d flag/@/+v/botnick etc.), can also be done at the moment you type .next. This will keep your bookkeeping simple.


<font size=-1>[ This Message was edited by: egghead on 2002-04-10 12:51 ]</font>
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

1) What to look for in here => http://www.scriptics.com/doc/ ? Get a manual or something like this?
2) I sow many scripts with [foreach], made some easy ones with it but I'm not so shure how to use it for a $list.
3) For SPLT I must use next:purge.. right?
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Using egghead coments, sugestions and reading some .doc files I finished the next:voice proc :smile: If I'm not wrong this should look something like this:

# .next
proc next:voice {nick uhost handle chan arg} {
global voicelist
if {$voicelist($chan) == ""} {
putserv "NOTICE $nick :List for $chan is empty."
return 1}
if {[botisop $voicelist($chan)]} {
foreach voiceuser $voicelist($chan) {
set user [nick2hand $voiceuser $voicelist($chan)]
if {[isop $voiceuser $voicelist($chan)]} {continue}
if {[isvoice $voiceuser $voicelist($chan)]} {continue}
if {[validuser $user] && [matchattr $user d]} {continue}
putserv "MODE $voicelist($chan) +v $voiceuser"
break }
return 1}
putserv "NOTICE $nick :I'm not oped on $voicelist($chan). :sad:"
}

Any sugestions for this proc? :smile:
I have read about this SPLT and REJN and my conclusion is that when a user get's a split (SPLT is triggered when someone gets netsplit on the channel) is in fact a signoff or something like this and a REJN (when someone who was splited has rejoined channel) is something like a join on the channel.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Is there someone who can give me some advices about this? except Egghead who is not in town.. :smile: Thanks.. advices will be apreciated.. :smile:
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

The add proc should look like:
proc next:add {nick uhost handle chan} {

the replace:
proc next:purge {nick uhost handle chan msg} {

replace:
proc next:replace {nick uhost handle chan newnick} {

Then, the add proc, with:
set voicelist [lappend $voicelist $nick]
is eating my $voicelist, make's the list only with the nick that joins the channel, makes the list contain only 1 nick.

I changed the folowing things:

# add
proc next:add {nick uhost handle chan} {
global botnick voicelist
if {$nick == $botnick} { return }
set voicelist [lappend $voicelist $nick]
}

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

# replace
proc next:replace {nick uhost handle chan newnick} {
global botnick voicelist
if {$nick == $botnick} { return }
set index [lsearch -exact $voicelist $nick]
set voicelist [lreplace $voicelist $index $index $newnick]
}

I tested: a kick and I get "TCL error [next:purge]: called "next:purge" with too many arguments" meens (I think) that I must make a proc for each: KICK, PART, SIGN and SPLT.

# .next
proc next:voice {nick uhost handle chan arg} {
global voicelist
if {$voicelist == "" } {
putserv "NOTICE $nick :Voicelist is empty."
return }
if {[botisop $chan]} {
foreach user $voicelist {
if {[validuser $user] || [isop $user $chan] || [isvoice $user $chan]} {
set index [lsearch -exact $voicelist $user]
set voicelist [lreplace $voicelist $index $index ]
continue }
putserv "MODE $chan +v $user"
set index [lsearch -exact $voicelist $user]
set voicelist [lreplace $voicelist $index $index ]
break }
return }
putserv "NOTICE $nick :I don't have an @ on $chan.." }

my .next proc is a bit messy, I'll fix it later..

Well, this is all, right now. :smile:
Sugestions, comments?.. reply!
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

The first thing that jumps out is incorrect lappend syntax.

lappend voicelist $nick

That will add $nick to voicelist. You don't need set or brackets around it.

I'd look at it more carefully but I have to go.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Like this looks my project right now.. :smile:

# version 0.4

# the list
set voicelist {}

# binds
bind join - * next:add
bind rejn - * next:add
bind part - * next:purge
bind sign - * next:purge
bind nick - * next:replace
bind kick - * kick:purge
bind splt - * purge:purge
bind pub n .next next:voice

# says the list
bind pub n .list next:list

# join & rejn
proc next:add {nick uhost handle chan} {
global botnick voicelist
if {$nick == $botnick} { return }
set voicelist lappend $voicelist $nick
}

# part & sign
proc next:purge {nick uhost handle chan msg} {
global botnick voicelist
if {$nick == $botnick} { return }
set index [lsearch -exact $voicelist $nick]
set voicelist [lreplace $voicelist $index $index ]
}

# splt
proc splt:purge {nick uhost handle chan} {
global botnick voicelist
if {$nick == $botnick} { return }
set index [lsearch -exact $voicelist $nick]
set voicelist [lreplace $voicelist $index $index ]
}

# kick
proc kick:purge {nick uhost handle chan vict reason} {
global botnick voicelist
if {$nick == $botnick} { return }
set index [lsearch -exact $voicelist $nick]
set voicelist [lreplace $voicelist $index $index ]
}

# nick
proc next:replace {nick uhost handle chan newnick} {
global botnick voicelist
if {$nick == $botnick} { return }
set index [lsearch -exact $voicelist $nick]
set voicelist [lreplace $voicelist $index $index $newnick]
}

# .next
proc next:voice {nick uhost handle chan arg} {
global voicelist
if {$voicelist == "" } {
putserv "NOTICE $nick :List is empty."
return }
if {[botisop $chan]} {
foreach voice $voicelist {
set user [nick2hand $voice $chan]
if {[validuser $user] || [isop $voice $chan] || [isvoice $voice $chan]} {
set index [lsearch -exact $voicelist $voice]
set voicelist [lreplace $voicelist $index $index ]
continue }
putserv "MODE $chan +v $voice"
set index [lsearch -exact $voicelist $voice]
set voicelist [lreplace $voicelist $index $index ]
break }
return }
putserv "NOTICE $nick :I don't have an @ on $chan." }

# list
proc next:list {nick uhost handle chan arg} {
global voicelist
if {$voicelist == "" } {
putserv "NOTICE $nick :List is empty."
return }
putserv "NOTICE $nick :List: $voicelist"
}

putlog ".next.. is loaded :smile:"

Problems
I Tested only with 1 nick when he get's voice or op in the channel, I must say .next twice so I can get the "List is empty." notice. I tested and I put in the list 2 nicks. At the first .next "foo" gets voice, then at the second .next "bar" gets voice. When I say the third .next I get that notice "List is empty."

Place
set place [lsearch -exact $voicelist $nick]
putserv "PRIVMSG $nick :you are the $place in the voice list."

This starts the places from 0. How to make it or an other one to start the counting from 1? I'm thinking to make it say to the nick the place is on when he was added to the list.

Thanks for the tip stdragon. As you can see I changed it. I'll test this to see if this add proc eats my list again. Thanks!

Coments, sugestions? Just give me an reply! :smile:
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

If this "set voicelist lappend $voicelist $nick" won't eat my list again, meens that .next is about to be finished. The only things that remain are the counting and some fixes of the codes.
Locked