Dandy did the regexp.
When one voiced user remain, the channel will be messaged with the winner nick/time/date, and in the topic as well.
Operators are not included in the "contest"
A user will lose the voice if they part/quit/or gets kicked, if a server splits, the server should give back the voice status.
This script uses eggdrops userflags to turn it on/off/or start the contest.
What to do:
change the channel name
change the trigger name (if you want to)
Commands:
- !trigger on - Prepares the channel, gives voice/autovoice on the channel.
!trigger start - starts right away.
!trigger start HH:MM DD/MM-YYYY - Starts on the specified time/date.
!trigger off - turns it off.
!trigger status - returns current status.
Two colors is used, well only one. (\003 = mIRC's ctrl+k)
If you change the theme or add something else, you are welcome to post it inhere.
I'm not much of theme maker.
- Code: Select all
setudef flag uptime
setudef flag uptime-start
setudef str uptime-date
setudef str uptime-usrpart
namespace eval uptime {
namespace eval variable {
variable channel "#uptime.dk"
variable trigger "!uptime"
variable flag "o|o"
variable c "\003"
variable c1 "\00307"
}
bind PUBM - "$::uptime::variable::channel $::uptime::variable::trigger*" [namespace current]::public
proc voiced {channel} {
set x 0
foreach user [chanlist $channel] {
if {[isbotnick $user]} {continue}
if {[isop $user $channel]} {continue}
if {[string length $user] == 1} {continue}
if {[isvoice $user $channel] == 1} {
incr x
}
}
return $x
}
proc voiced.nick {nickname channel} {
foreach user [chanlist $channel] {
if {[string match $nickname $user]} {continue}
if {[isbotnick $user]} {continue}
if {[isop $user $channel]} {continue}
if {[string length $user] == 1} {continue}
if {[isvoice $user $channel] == 1} {
return $user
}
}
}
proc public {nickname hostname handle channel text} {
set s [lindex $text 1]
switch $s {
on {
if {[matchattr $handle $::uptime::variable::flag $channel]} {
if {![channel get $channel uptime-start]} {
if {[channel get $channel uptime]} {
putserv "NOTICE $nickname :Uptime is already \002on\002 for $channel."
} else {
channel set $channel +uptime
foreach user [chanlist $channel] {
if {[isbotnick $user]} {continue}
if {[isop $user $channel]} {continue}
if {[string length $user] == 1} {continue}
pushmode $channel +v $user
}
putserv "PRIVMSG $channel :\002Preparing Uptime Contest\002. Autovoice is turned on."
}
}
}
}
off {
if {[matchattr $handle $::uptime::variable::flag $channel]} {
channel set $channel -uptime
channel set $channel -uptime-start
putserv "PRIVMSG $channel :\002Uptime Contest\002 is now turned off for $channel. $::uptime::variable::c1[channel get $channel uptime-usrpart]$::uptime::variable::c User(s) lost the voice. $::uptime::variable::c1[::uptime::voiced $channel]$::uptime::variable::c is still voiced."
foreach bind [binds time] {
if {[string match *contest [lindex $bind 4]]} {
unbind TIME - "[lindex $bind 2]" [lindex $bind 4]
}
}
}
}
start {
if {[matchattr $handle $::uptime::variable::flag $channel]} {
if {[channel get $channel uptime]} {
set s [lrange $text 2 end]
if {[string match *:* $s]} {
# Developed by Dandy - http://www.daasor.info/
regexp {([0-9]+):([0-9]+) ([0-9]+)/([0-9]+)-([0-9]+)} "$s" test1 hour minutes day month year
set month1 "0[expr $month-1]"
if {[string length $month1] > 2} { set month1 "[join [lrange [split $month1 ""] 1 end] ""]" }
if {[botisop $channel]} {
putserv "TOPIC $channel :\002Uptime Contest\002 will start on \002Time\002: $::uptime::variable::c1$hour:$minutes$::uptime::variable::c \002Date\002: $::uptime::variable::c1$day/$month$::uptime::variable::c \002Year\002: $::uptime::variable::c1$year$::uptime::variable::c."
}
bind TIME - "[list $minutes $hour $day $month1 $year]" [namespace current]::contest
putserv "PRIVMSG $channel :\002Uptime Contest\002 Time is set and will start on \002Time\002: $::uptime::variable::c1$hour:$minutes$::uptime::variable::c \002Date\002: $::uptime::variable::c1$day/$month$::uptime::variable::c \002Year\002: $::uptime::variable::c1$year$::uptime::variable::c."
} else {
channel set $channel uptime-usrpart 0
channel set $channel -uptime
channel set $channel +uptime-start
channel set $channel uptime-date "[clock format [unixtime] -format "%R %d/%m-%Y"]"
if {[botisop $channel]} {
putserv "TOPIC $channel :\002Uptime Contest\002 Started. \002Time\002: $::uptime::variable::c1[clock format [unixtime] -format %R]$::uptime::variable::c \002Date\002: $::uptime::variable::c1[clock format [unixtime] -format %d/%m]$::uptime::variable::c \002Year\002: $::uptime::variable::c1[clock format [unixtime] -format %Y]$::uptime::variable::c Starting with $::uptime::variable::c1\002[::uptime::voiced $channel]\002$::uptime::variable::c voiced users."
}
putserv "PRIVMSG $channel :\002Uptime Contest\002 is now Started. Autovoice is turned \002OFF\002, keep your voice, as long as you can. We are currently \002[::uptime::voiced $channel]\002 voiced users on the channel."
}
} else {
putserv "NOTICE $nickname :Uptime is required to be enabled first.."
}
}
}
status {
if {[channel get $channel uptime-start]} {
putserv "PRIVMSG $channel :\002Uptime Contest\002 is \002ON\002 Status: $::uptime::variable::c1[channel get $channel uptime-usrpart]$::uptime::variable::c User(s) lost the voice. $::uptime::variable::c1[::uptime::voiced $channel]$::uptime::variable::c users remain, since $::uptime::variable::c1[channel get $channel uptime-date]$::uptime::variable::c"
} else {
if {[channel get $channel uptime]} {
putserv "PRIVMSG $channel :\002Uptime Contest Preparing\002 is on, autovoice is \002ON\002."
} else {
putserv "PRIVMSG $channel :\002Uptime Contest Preparing\002 is off, autovoice is \002OFF\002."
}
}
}
default {
if {[channel get $channel uptime]} {
putserv "NOTICE $nickname :Uptime is \002on\002 for $channel"
} else {
putserv "NOTICE $nickname :Uptime is \002off\002 for $channel"
}
}
}
}
putlog "\00304[string range [info script] 0 end]\00304 \002loaded\003\002. By \002http://sp00fed.org\002"
proc contest {minute hour day month year} {
catch { unbind TIME - "$minute $hour $day $month $year" [namespace current]::contest }
set channel "$::uptime::variable::channel"
# Developed by Dandy - http://www.daasor.info/
regexp {([0-9]+):([0-9]+) ([0-9]+)/([0-9]+)-([0-9]+)} "[clock format [unixtime] -format "%R %d/%m-%Y"]" test1 hour minutes day month year
if {[botisop $channel]} {
putserv "TOPIC $channel :\002Uptime Contest\002 Started. \002Time\002: $::uptime::variable::c1$hour:$minute$::uptime::variable::c \002Date\002: $::uptime::variable::c1$day/$month$::uptime::variable::c \002Year\002: $::uptime::variable::c1$year$::uptime::variable::c. Starting with $::uptime::variable::c1\002[::uptime::voiced $channel]\002$::uptime::variable::c voiced users."
}
channel set $channel uptime-usrpart 0
channel set $channel -uptime
channel set $channel +uptime-start
channel set $channel uptime-date "[clock format [unixtime] -format "%R %d/%m-%Y"]"
putserv "PRIVMSG $channel :\002Uptime Contest\002 is now Started. Autovoice is turned \002OFF\002, keep your voice, as long as you can. We are currently $::uptime::variable::c1\002[::uptime::voiced $channel]\002$::uptime::variable::c voiced users on the channel."
}
bind JOIN - * [namespace current]::join
proc join {nickname hostname handle channel} {
if {[botisop $channel]} {
if {[channel get $channel uptime]} {
pushmode $channel +v $nickname
}
}
}
bind PART - * [namespace current]::remove
bind SIGN - * [namespace current]::remove
bind KICK - * [namespace current]::kick
proc kick {nickname hostname handle channel target message} {
::uptime::remove $target $hostname $handle $channel $message
}
proc remove {nickname hostname handle channel message} {
if {[channel get $channel uptime-start]} {
if {[isvoice $nickname $channel]} {
channel set $channel uptime-usrpart [expr [channel get $channel uptime-usrpart]+1]
if {[expr [::uptime::voiced $channel]-1] == 1} {
putserv "PRIVMSG $channel :We have a winner, $::uptime::variable::c1[::uptime::voiced.nick $nickname $channel]$::uptime::variable::c."
# Developed by Dandy - http://www.daasor.info/
regexp {([0-9]+):([0-9]+) ([0-9]+)/([0-9]+)-([0-9]+)} "[clock format [unixtime] -format "%R %d/%m-%Y"]" test1 hour minutes day month year
regexp {([0-9]+):([0-9]+) ([0-9]+)/([0-9]+)-([0-9]+)} "[channel get $channel uptime-date]" test1 hour1 minutes1 day1 month1 year1
if {[botisop $channel]} {
putserv "TOPIC $channel :\002Uptime Contest\002 Started on \002Time\002: $::uptime::variable::c1$hour1:$minutes1$::uptime::variable::c \002Date\002: $::uptime::variable::c1$day1/$month1$::uptime::variable::c \002Year\002: $::uptime::variable::c1$year1$::uptime::variable::c. Won by $::uptime::variable::c1\002[::uptime::voiced.nick $nickname $channel]\002$::uptime::variable::c at \002Time\002: $::uptime::variable::c1$hour:$minutes$::uptime::variable::c \002Date\002: $::uptime::variable::c1$day/$month$::uptime::variable::c \002Year\002: $::uptime::variable::c1$year$::uptime::variable::c."
}
channel set $channel -uptime-start
} else {
putserv "PRIVMSG $channel :$::uptime::variable::c1[expr [::uptime::voiced $channel]-1]$::uptime::variable::c voiced users remain. $::uptime::variable::c1[channel get $channel uptime-usrpart]$::uptime::variable::c user(s) lost the voice."
}
}
}
}
}
Enjoy