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.

Modifying !topidle to remove bots

Help for those learning Tcl or writing their own scripts.
Post Reply
M
MIODude
Voice
Posts: 32
Joined: Mon Oct 09, 2006 6:26 pm

Modifying !topidle to remove bots

Post by MIODude »

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?

Thanks in Advance!

Code: Select all

#---------------------------------------------------------------------
# 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."

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

Post by caesar »

change from:

Code: Select all

   foreach idler $candidates {
      set idletime [getchanidle $idler $chan]
      set idlelist [lappend idlelist "$idler $idletime"]
   } 
to:

Code: Select all

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.
M
MIODude
Voice
Posts: 32
Joined: Mon Oct 09, 2006 6:26 pm

Post by MIODude »

Thank you!
M
MIODude
Voice
Posts: 32
Joined: Mon Oct 09, 2006 6:26 pm

Post by MIODude »

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..

Am I missing something easy?
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

I forgot to mention that you can change the 'b' flag to whatever you wish.

You've changed from:

Code: Select all

if {![matchattr [nick2hand $idler] b]}
to:

Code: Select all

if {![matchattr [nick2hand $idler] b $chan]}
when you wanted to the channel specific flag?
Once the game is over, the king and the pawn go back in the same box.
M
MIODude
Voice
Posts: 32
Joined: Mon Oct 09, 2006 6:26 pm

Post by MIODude »

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 :)
Post Reply