Communauté francophone sur les Eggdrops
Top 5 idlers script - Printable Version

+- Communauté francophone sur les Eggdrops (https://forum.eggdrop.fr)
+-- Forum: English help (https://forum.eggdrop.fr/forumdisplay.php?fid=25)
+--- Forum: Tcl Scripts (https://forum.eggdrop.fr/forumdisplay.php?fid=29)
+---- Forum: Script Support & Releases (https://forum.eggdrop.fr/forumdisplay.php?fid=32)
+---- Thread: Top 5 idlers script (/showthread.php?tid=1862)



Top 5 idlers script - mabrook - 14/10/2021

need help a little on this script, please

tcl
#############################################################################################
#                                                                                          #
# Idle Top 5!                                                                              #
# Based on Idle King script by Ozh.                                                        #
# That script was originally named "Idle des jeunes" in French, which is funny as hell.    #
#                                                                                          #
# Contact stuff :                                                                          #
# TrashF, TrashF@iki.fi, QuakeNet.                                                          #
#                                                                                          #
#############################################################################################
 
#just type !idle on channel to get the top 5 idlers
 
bind pub - !idle idle_getnick
 
proc idle_getnick {nick mask hand chan args} {
global botnick
set idlaajia 0 
set idle_1 "0"
set idle_2 "0"
set idle_3 "0"
set idle_4 "0"
set idle_5 "0"
set idle_1_nick "N/A"
set idle_2_nick "N/A"
set idle_3_nick "N/A"
set idle_4_nick "N/A"
set idle_5_nick "N/A"
foreach mec [chanlist $chan] {
set idle_idle [getchanidle $mec $chan]
if {$idle_idle > $idle_1 && $mec != $botnick && $mec != "L"} {set idle_1 $idle_idle ; set idle_1_nick $mec ; incr idlaajia }
}
foreach mec [chanlist $chan] {
set idle_idle [getchanidle $mec $chan]
if {$idle_idle > $idle_2 && $mec != $idle_1_nick && $mec != $botnick && $mec != "L"} {set idle_2 $idle_idle ; set idle_2_nick $mec ; incr idlaajia}
}
foreach mec [chanlist $chan] {
set idle_idle [getchanidle $mec $chan]
if {$idle_idle > $idle_3 && $mec != $idle_1_nick && $mec != $idle_2_nick && $mec != $botnick && $mec != "L"} {set idle_3 $idle_idle ; set idle_3_nick $mec ; incr idlaajia}
}
foreach mec [chanlist $chan] {
set idle_idle [getchanidle $mec $chan]
if {$idle_idle > $idle_4 && $mec != $idle_1_nick && $mec != $idle_2_nick && $mec != $idle_3_nick && $mec != $botnick && $mec != "L"} {set idle_4 $idle_idle ; set idle_4_nick $mec ; incr idlaajia}
}
foreach mec [chanlist $chan] {
set idle_idle [getchanidle $mec $chan]
if {$idle_idle > $idle_5 && $mec != $idle_1_nick && $mec != $idle_2_nick && $mec != $idle_3_nick && $mec != $idle_4_nick && $mec != $botnick && $mec != "L"} {set idle_5 $idle_idle ; set idle_5_nick $mec ; incr idlaajia}
}
 
#here you can change the output method if you want.
if {$idlaajia > "5"} {set idlaajia 5}
putchan $chan "# Top $idlaajia Idlers #" 
if {$idle_1_nick != "N/A"} { putchan $chan "\00304#1.\003 \00302$idle_1_nick\003 ($idle_1 minutes); \00304#2.\003 \00302$idle_2_nick\003 ($idle_2 minutes); \00304#3.\003 \00302$idle_3_nick\003 ($idle_3 minutes); \00304#4.\003 \00302$idle_4_nick\003 ($idle_4 minutes); \00304#5.\003 \00302$idle_5_nick\003 ($idle_5 minutes)" }
}
 
putlog "Idle Top 5 by TrashF @ QNet loaded."




output is 

tcl
<user>!idle
<bot> # Top 5 Idlers #
<bot> #1. user1 (455 minutes); #2. user2 (455 minutes); #3. user3 (455 minutes); #4. user4 (455 minutes); #5. user5 (455 minutes);




now i want the output like this:

tcl
<user>!idle
<bot> # Top 5 Idlers #
<bot> #1. user1 (1d:4h:22m:22s); #2. user2 (2d:4h:22m:22s); #3. user3 (3d:4h:22m:22s); #4. user4 (4d:4h:22m:22s); #5. user5 (5d:4h:22m:22s)




thank you all..


RE: Top 5 idlers script - BLaCkShaDoW - 14/10/2021

tcl
proc return_time {get_time} {
set seconds [expr $get_time % 60]
set days [expr $get_time/86400]
set hours [expr [expr $get_time/3600] % 24];
set minutes [expr [expr $get_time / 60] % 60]
 
if {[string length $hours] == "1"} {
set hours "0${hours}"
}
if {[string length $minutes] == "1"} {
set minutes "0${minutes}"
}
if {[string length $seconds] == "1"} {
set seconds "0${seconds}"
}
set output "${days}d:${hours}h:${minutes}m:${seconds}s"
if {$get_time <= 0} {
return 0
} else {
return $output
}
}



Place this code in the script then replace
tcl
if {$idle_1_nick != "N/A"} { putchan $chan "\00304#1.\003 \00302$idle_1_nick\003 ($idle_1 minutes); \00304#2.\003 \00302$idle_2_nick\003 ($idle_2 minutes); \00304#3.\003 \00302$idle_3_nick\003 ($idle_3 minutes); \00304#4.\003 \00302$idle_4_nick\003 ($idle_4 minutes); \00304#5.\003 \00302$idle_5_nick\003 ($idle_5 minutes)" }


with
tcl
if {$idle_1_nick != "N/A"} { putchan $chan "\00304#1.\003 \00302$idle_1_nick\003 ([return_time [expr $idle_1 * 60]]); \00304#2.\003 \00302$idle_2_nick\003 ([return_time [expr $idle_2 * 60]]); \00304#3.\003 \00302$idle_3_nick\003 ([return_time [expr $idle_3 * 60]]); \00304#4.\003 \00302$idle_4_nick\003 ([return_time [expr $idle_4 * 60]]); \00304#5.\003 \00302$idle_5_nick\003 ([return_time [expr $idle_5 * 60]])" }



Didn't test it. Code copied and modified from BlackTools.


RE: Top 5 idlers script - mabrook - 14/10/2021

i got this error


tcl
<user> .errorInfo
<bot> [11:07:57] ----------------
<bot> [11:07:57] invalid bareword "minutes"
<bot> in expression "560 minutes * 60";
<bot> should be "$minutes" or "{minutes}" or "minutes(...)" or ...
<bot>    (parsing expression "560 minutes * 60")
<bot>    invoked from within
<bot> "expr $idle_3 minutes * 60"
<bot>    (procedure "idle_getnick" line 61)
<bot>    invoked from within
<bot> "idle_getnick $_pub1 $_pub2 $_pub3 $_pub4 $_pub5"
<bot> [11:07:57] errorCode : TCL PARSE EXPR BAREWORD
<bot> [11:07:57] ----------------





RE: Top 5 idlers script - BLaCkShaDoW - 14/10/2021

try again


RE: Top 5 idlers script - mabrook - 14/10/2021

it is working, but i think the "(0d:09h:38m:00s)" is not properly showing.. it's all the same..

1st try 

tcl
<bot> #1. user1 (0d:09h:38m:00s); #2. user2 (0d:09h:38m:00s); #3. user3 (0d:09h:38m:00s); #4. user4 (0d:09h:38m:00s); #5. user5 (0d:09h:38m:00s)



then after how many minutes;

tcl
<bot> #1. user1 [0d:10h:00m:00s]; #2. user2 [0d:10h:00m:00s]; #3. user3 [0d:10h:00m:00s]; #4. user4 [0d:10h:00m:00s]; #5. user5 [0d:10h:00m:00s]




"(0d:09h:38m:00s)" still not showing the proper counts.. but i am not sure.. 

one thing im sure the users not be the same time.. 


and please, can you add the code for chanset #channel +idlers  in the code

please...


RE: Top 5 idlers script - BLaCkShaDoW - 14/10/2021

Add after this line
tcl
global botnick


the following line
tcl
if {![channel get $chan idlers]} { return }



The "getchanidle" process used gets the idle based on the eggdrops perspective. So if the eggdrop joins it sees everyone with the same idle. But if another user joins after the eggdrop it has another idle. So thats why almost all users have the same idle.


RE: Top 5 idlers script - mabrook - 15/10/2021

i tried it, i hope im in the right place inserting the code


tcl
#just type !idlers on channel to get the top 5 idlers
 
bind pub - !idlers idle_getnick
 
proc idle_getnick {nick mask hand chan args} {
global botnick
if {![channel get $chan idlers]} { return }
set idlaajia 0 
set idle_1 "0"




and i got this,

tcl
<bot> [04:44:55] ----------------
<bot> [04:44:55] illegal channel option: +idlers
<bot> 
<bot>    while executing
<bot> "channel set $chan $flags"
<bot> [04:44:55] errorCode : NONE






Quote:The "getchanidle" process used gets the idle based on the eggdrops perspective. So if the eggdrop joins it sees everyone with the same idle. But if another user joins after the eggdrop it has another idle. So thats why almost all users have the same idle.


noted on this.  :))))


RE: Top 5 idlers script - CrazyCat - 15/10/2021

Your script lacks setudef flag idlers at the beginning, before (or after, not really important) the bind pub - !idlers idle_getnick line


RE: Top 5 idlers script - mabrook - 15/10/2021

thank you CrazyCat and BLaCkShaDoW for helping out.. Now is working .. :))