I don't know you, as it's your first post here, how can you tell that ?sauk wrote:I don't know if you can help me, but I see for example CrazyCat very active around here and he doesn't mind helping me anyway.
CrazyCat wrote:I don't know you, as it's your first post here, how can you tell that ?sauk wrote:I don't know if you can help me, but I see for example CrazyCat very active around here and he doesn't mind helping me anyway.
This kind of script is quite simple to do, but like I don't mind helping you (dixit you), I won't help you.
Best regards.
I wanted to say:I don't know if you can help me, but I see for example CrazyCat very active around here and he doesn't mind helping me anyway.
I don't know if you can help me, but I see for example CrazyCat very active around here and I wonder if he doesn't mind helping me.
Code: Select all
namespace eval uptime {
# Change the trigger if you want
variable trigger "!start"
# Do not modify
variable players
bind pub -|- $::uptime::trigger ::uptime::start
proc start {nick uhost handle chan text} {
if {[info exists ::uptime::players($chan)] && [llength ::uptime::players($chan)]>0} { return }
set ::uptime::players($chan) {}
foreach u [chanlist $chan] {
if {[isbotnick $u]} { continue }
pushmode $chan +v $u
lappend ::uptime::players($chan) $u
}
flushmode $chan
putserv "PRIVMSG $chan :Uptime contest is now running!"
}
bind nick - * ::uptime::renuser
proc renuser {nick uhost handle chan nnick} {
if {![info exists ::uptime::players($chan)]} { return }
set ind [lsearch $::uptime::players($chan) $nick]
if { $ind > -1} {
set ::uptime::players($chan) [lreplace $::uptime::players($chan) $ind $ind $nnick]
}
}
bind part - * ::uptime::part
proc part {nick uhost handle chan text} {
if {![info exists ::uptime::players($chan)]} { return }
::uptime::lose $chan $nick
}
bind sign - * ::uptime::sign
proc sign {nick uhost handle chan text} {
if {![info exists ::uptime::players($chan)]} { return }
::uptime::lose $chan $nick
}
proc lose {chan nick} {
if {![info exists ::uptime::players($chan)]} { return }
set ind [lsearch $::uptime::players($chan) $nick]
if {$ind > -1} {
putserv "PRIVMSG $chan :$nick is no more playing ! LoOose !"
set ::uptime::players($chan) [lreplace $::uptime::players($chan) $ind $ind]
}
if {[llength $::uptime::players($chan)]==1} {
putserv "PRIVMSG $chan :And the winner is... [lindex $::uptime::players($chan) 0]"
unset ::uptime::players($chan)
}
}
}
Code: Select all
namespace eval uptime {
variable triggerS "!start"
variable triggerE "!stop"
# list of excluded nick
variable excluded {$::botnick "Q" "ChanServ" "\[Bot1\]"}
# Format of the date (see strftime documentation)
variable tformat "%d/%m/%Y %H:%M:%S"
# precision of the duration
variable precision 3
variable players
bind pub -|- $::uptime::triggerS ::uptime::start
bind pub -|n $::uptime::triggerE ::uptime::stop
variable tstart
proc start {nick uhost handle chan text} {
if {[info exists ::uptime::players($chan)] && [llength ::uptime::players($chan)]>0} { return }
set ::uptime::players($chan) {}
foreach u [chanlist $chan] {
if {[isbotnick $u] || [lsearch -nocase $::uptime::excluded $u]>-1} { continue }
pushmode $chan +v $u
lappend ::uptime::players($chan) $u
}
flushmode $chan
set ::uptime::tstart [clock seconds]
putserv "TOPIC $chan :New Uptime contest started at [clock format $::uptime::tstart -format $::uptime::tformat]"
putserv "PRIVMSG $chan :Uptime contest is now running!"
}
proc stop {nick uhost handle chan text} {
if {![info exists ::uptime::players($chan)] || [llength ::uptime::players($chan)]==0} { return }
foreach u $::uptime::players($chan) {
pushmode $chan -v $u
}
flushmode $chan
unset ::uptime::players($chan)
unset ::uptime::tstart
putserv "PRIVMSG $chan :Uptime contest stopped by $nick"
putserv "TOPIC $chan :Uptime contest stopped by $nick at [clock format [clock seconds] -format $::uptime::tformat]"
}
bind nick - * ::uptime::renuser
proc renuser {nick uhost handle chan nnick} {
if {![info exists ::uptime::players($chan)]} { return }
set ind [lsearch $::uptime::players($chan) $nick]
if { $ind > -1} {
set ::uptime::players($chan) [lreplace $::uptime::players($chan) $ind $ind $nnick]
}
}
bind part - * ::uptime::part
proc part {nick uhost handle chan text} {
if {![info exists ::uptime::players($chan)]} { return }
::uptime::lose $chan $nick
}
bind sign - * ::uptime::sign
proc sign {nick uhost handle chan text} {
if {![info exists ::uptime::players($chan)]} { return }
::uptime::lose $chan $nick
}
bind kick - * ::uptime::kick
proc kick {nick uhost handle chan target reason} {
if {![info exists ::uptime::players($chan)]} { return }
::uptime::lose $chan $target
}
proc lose {chan nick} {
if {![info exists ::uptime::players($chan)]} { return }
set ind [lsearch $::uptime::players($chan) $nick]
if {$ind > -1} {
putserv "PRIVMSG $chan :$nick is no more playing ! LoOose !"
set ::uptime::players($chan) [lreplace $::uptime::players($chan) $ind $ind]
}
if {[llength $::uptime::players($chan)]==1} {
putserv "PRIVMSG $chan :And the winner is... [lindex $::uptime::players($chan) 0]"
putserv "TOPIC $chan :Uptime contest finished ([clock format $::uptime::tstart -format $::uptime::tformat] - [clock format [clock seconds] -format $::uptime::tformat]) - Uptime winner is [lindex $::uptime::players($chan) 0] with [::uptime::duration $::uptime::tstart]"
unset ::uptime::players($chan)
}
}
proc duration {start {end 0}} {
set slang {year month day hour minute second}
if {$end eq 0} {
set end [clock seconds]
}
set out {}
set years [expr {[clock format $end -format %Y] - [clock format $start -format %Y]}]
set delay [clock format [expr {$end - $start}] -format "%m-%d %H:%M:%S"]
regexp {(\d+)-(\d+) 0?(\d+):0?(\d+):0?(\d+)} $delay -> months days hours minutes seconds
set tdata [list $years [incr months -1] [incr days -1] [incr hours -1] $minutes $seconds]
set i 0
foreach val $tdata {
if {$val > 0} {
if {$val>1} { set s "s" } else { set s "" }
lappend out "$val [lindex $slang $i]$s"
}
incr i
}
if {$::uptime::precision <= 2 || [llength $out]<$::uptime::precision} {
set tmpret [join [lrange $out 0 [expr {$::uptime::precision - 1}]] " and "]
} else {
set tmpret [join [lrange $out 0 [expr {$::uptime::precision - 2}]] ", "]
set tmpret "$tmpret and [join [lindex $out [expr {$::uptime::precision - 1}]]]"
}
return $tmpret
}
putlog "Uptime Contest v220521 by CrazyCat <https://forum.eggdrop.fr> Loaded"
}
#test wrote:16:06:56 <CrazyCat> !start
16:06:57 -- Raspdrop a changé le titre pour #test de "Uptime contest finished (21/05/2022 - 15:43:46 - 21/05/2022 - 16:02:40) - Uptime winner is CrazyCat in 18 minutes and 54 seconds" en "New Uptime contest started at 21/05/2022 16:06:56"
16:06:58 <Raspdrop> Uptime contest is now running!
16:07:19 <-- CrazyCat a éjecté Myrddin (just a trys)
16:07:20 --> Myrddin [Excalibur] (http://www.eggdrop.fr) (Myrddin@eggdrop.fr) a rejoint #test
16:07:20 <Raspdrop> Myrddin is no more playing ! LoOose !
16:07:53 -- Mode #test [+o Raspdrop] par CrazyCat
16:08:07 <-- Z (4ed93d66@zeolia-D3E23F37) a quitté (Quit: Connection closed)
16:08:08 <@Raspdrop> Z is no more playing ! LoOose !
16:08:09 <@Raspdrop> And the winner is... CrazyCat
16:08:10 -- Raspdrop a changé le titre pour #test de "New Uptime contest started at 21/05/2022 16:06:56" en "Uptime contest finished (21/05/2022 16:06:56 - 21/05/2022 16:08:07) - Uptime winner is CrazyCat with 1 minute and 11 seconds"
Also will be great when contest finishes on the topic upgrade setup a counter with total finished contests.putserv "TOPIC $chan :New Uptime contest started at [clock format $::uptime::tstart -format $::uptime::tformat] - Prize: .com domain"
putserv "TOPIC $chan :Uptime contest finished ([clock format $::uptime::tstart -format $::uptime::tformat] - [clock format [clock seconds] -format $::uptime::tformat]) - Uptime winner is [lindex $::uptime::players($chan) 0] with [::uptime::duration $::uptime::tstart]" - Total contests: 30