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 

Modifying !topidle to remove bots

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


Joined: 09 Oct 2006
Posts: 32

PostPosted: Sun May 30, 2010 11:34 pm    Post subject: Modifying !topidle to remove bots Reply with quote

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:

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

Back to top
View user's profile Send private message
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Mon May 31, 2010 3:29 am    Post subject: Reply with quote

change from:
Code:

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

to:
Code:

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. Smile
_________________
Once the game is over, the king and the pawn go back in the same box.
Back to top
View user's profile Send private message
MIODude
Voice


Joined: 09 Oct 2006
Posts: 32

PostPosted: Mon May 31, 2010 7:59 am    Post subject: Reply with quote

Thank you!
Back to top
View user's profile Send private message
MIODude
Voice


Joined: 09 Oct 2006
Posts: 32

PostPosted: Wed Jun 02, 2010 8:21 am    Post subject: Reply with quote

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?
Back to top
View user's profile Send private message
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Thu Jun 03, 2010 5:16 am    Post subject: Reply with quote

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

You've changed from:
Code:

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

to:
Code:

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.
Back to top
View user's profile Send private message
MIODude
Voice


Joined: 09 Oct 2006
Posts: 32

PostPosted: Thu Jun 03, 2010 8:06 am    Post subject: Reply with quote

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 Smile
Back to top
View user's profile Send private message
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