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.

Uptime contest

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
s
sauk
Voice
Posts: 16
Joined: Sun Jul 05, 2020 4:33 am

Uptime contest

Post by sauk »

Hello everybody.

I have failed in my internet search for possible old scripts from uptime contest (for example on Quakenet).

And I come here to ask, first, if anyone has one already scripted and published, and if not, if someone would help me with the script.

The function of the script is to make an UPTIME championship with all the users in channel X, therefore:

1-When we execute the !start command, the competition will start and the bot will grant +v to all users in that channel. (And the bot will save the list of users, with the information for example of the hosts)
2-When a user who had +v in the channel does quit/part, the bot will announce with a say that that user has been eliminated from the competition.
3-The last user to lose their connection and therefore leave the channel will win. (This would be fine if the bot logs in for a number every time someone lands so that if you're not online you can look at it later).

PS: After the competition has started the bot should not give any more +v to anyone, so simply by looking at the list of people who have a voice in the channel you will know who is still in force in the championship.
Another idea is that when the last user falls, the bot can automatically publish the winner in the channel topic, for example.

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.

Thanks in advance.


Idea based on http://uptime.quakenut.org/quicklink/page/help (There you can probably understand something that I have not explained well)
User avatar
CrazyCat
Revered One
Posts: 1301
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Re: Uptime contest

Post by CrazyCat »

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.
I don't know you, as it's your first post here, how can you tell that ?
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.
s
sauk
Voice
Posts: 16
Joined: Sun Jul 05, 2020 4:33 am

Re: Uptime contest

Post by sauk »

CrazyCat wrote:
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.
I don't know you, as it's your first post here, how can you tell that ?
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 have probably expressed myself badly because I wanted to translate the text so that it remains without errors and I think that it has made a mistake.

I wanted to say in that sentence that you quoted, let's see if someone, for example your CrazyCat, could lend me a hand.

If you don't mind using your time to help me which I appreciate, but I see that it is mistranslated and interpreted and sorry for that.
s
sauk
Voice
Posts: 16
Joined: Sun Jul 05, 2020 4:33 am

Post by sauk »

That is, my sentence was to praise your work here and not to despise it.

In order 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 wanted to say:
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.
User avatar
CrazyCat
Revered One
Posts: 1301
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

Ok, no trouble :)

I'll work on that today, will post code in a few hours
User avatar
CrazyCat
Revered One
Posts: 1301
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

few hours later:

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)
		}
	}
}
Actually the script doesn't save winners and anyone on the chan can launch the game.
s
sauk
Voice
Posts: 16
Joined: Sun Jul 05, 2020 4:33 am

Post by sauk »

Let me test and I will give you feedback, thank you mate.
s
sauk
Voice
Posts: 16
Joined: Sun Jul 05, 2020 4:33 am

Post by sauk »

A command for manual stopping the contest and clearing DB will be usefull.

Also if player got kicked should be removed from it.
s
sauk
Voice
Posts: 16
Joined: Sun Jul 05, 2020 4:33 am

Post by sauk »

Giving more feedback, bot needs to ignore for example service names or contest will never finish. In this case for example

Q or ChanServ
s
sauk
Voice
Posts: 16
Joined: Sun Jul 05, 2020 4:33 am

Post by sauk »

Thinking to do a complete script would be great,

When we launch the contest with !start the bot should change topic to a for example:

"New #Uptime contest started at $date"

And when the contest finishes the bot should upgrade the current topic setting with

"Update contest finished ($startdate/$finishdate) - Total Update championships: $counter - Last winner: $winner


You know what I'm telling? I don't know if im explaining badly
User avatar
CrazyCat
Revered One
Posts: 1301
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

All the thing you ask are quite easy to add.
The only question is about stoping game: who can stop it ? The initial launcher, the chan owner, any op or halfop, ... ?
s
sauk
Voice
Posts: 16
Joined: Sun Jul 05, 2020 4:33 am

Post by sauk »

I already added n|n on the start command, so only bot owner can start.

Bot owner should be able to stop only.
User avatar
CrazyCat
Revered One
Posts: 1301
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

New version :

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"
Last edited by CrazyCat on Sun May 22, 2022 7:05 am, edited 1 time in total.
s
sauk
Voice
Posts: 16
Joined: Sun Jul 05, 2020 4:33 am

Post by sauk »

I will test soon, and reply after. Thank you
s
sauk
Voice
Posts: 16
Joined: Sun Jul 05, 2020 4:33 am

Post by sauk »

Very good job, we can upgrade..

Seting up a command !setprize and setting add the prize of the contest, example:

!setprize .com domain

Then the bot when we start the contest puts also the prize in topic.
Like:
putserv "TOPIC $chan :New Uptime contest started at [clock format $::uptime::tstart -format $::uptime::tformat] - Prize: .com domain"
Also will be great when contest finishes on the topic upgrade setup a counter with total finished contests.

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