The code below pulls the top 3 idlers in a channel. We have several eggdrop bots in there, so we don't want to include those - whats the best way to create a list of exclusions? Is there a way as its populating the variable rankings that if it matches a nick it does get added?
#---------------------------------------------------------------------
# goldensilence.tcl
# TCL script for IRC bot eggdrop
# Upon public trigger "!topidle" awards gold, silver and bronze
# medals for top 3 idlers.
#
# Note: requires TCL version 8 (version test not included in script)
#
# v0: 26-Feb-2002
#---------------------------------------------------------------------
bind pub - !topidle topidlers
proc topidlers { nick uhost hand chan text } {
# make a list of nicks and strip out bot
set candidates [lrange [chanlist $chan] 1 end]
# No gold/silver/bronze if less than 3 :)
if {[llength $candidates] < 3} {
puthelp "PRIVMSG $chan :Silence is golden. No game in progress."
return
}
# make a list of sub-lists (nickname idletime)
foreach idler $candidates {
set idletime [getchanidle $idler $chan]
set idlelist [lappend idlelist "$idler $idletime"]
}
# sort on idle time (element 1 of each sub-list)
# no sharing of medals, lsort determines the ranking...
set ranking [lsort -index 1 -integer -decreasing $idlelist]
# assign medals
set gold [lindex $ranking 0]
set silv [lindex $ranking 1]
set bron [lindex $ranking 2]
# prepare to output to channel
set gold "GOLD: [lindex $gold 0] (idle [lindex $gold 1] min.)"
set silv "SILVER: [lindex $silv 0] (idle [lindex $silv 1] min.)"
set bron "BRONZE: [lindex $bron 0] (idle [lindex $bron 1] min.)"
# make winners public...
puthelp "PRIVMSG $chan :Silence is golden! $gold $silv $bron"
# log who triggered...
return 1
}
putlog "Loaded (version 0): Idle game."
foreach idler $candidates {
if {![matchattr [nick2hand $idler] b]} {
set idletime [getchanidle $idler $chan]
set idlelist [lappend idlelist "$idler $idletime"]
}
}
where 'b' (bot) is the flag you wish to be excluded from the list. You can add '$chan' after 'b' if you wish to have a channel specific flag or change the flag.
Once the game is over, the king and the pawn go back in the same box.
hmm.. i thought i had this working, but it was actually the restart of the bot that reset the counters..
I can't set the +b for some reason? I do the .chattr nick +b and it then lists the global flags, and +b isn't there? I thought maybe it was a channel specific flag, so tried .chattr nick +b #channel but that didn't work either..
I didn't really need it to be channel specific, so I left it, and I kept it as b, since that is the bot flag (made sense to me!).. but i can't add that flag to the bots.. it just doesn't stay.. it says its being added, but when i check the flags later, there is no b
edit: Ok - I found another post where it says you can't set +b... so I've changed it to the f now