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.

Peak Script Request (Not the one you think)

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
F
Football
Master
Posts: 205
Joined: Fri Dec 26, 2008 3:08 pm
Location: Quakenet, #Football

Peak Script Request (Not the one you think)

Post by Football »

Hey, I`m looking for a script where you can output to the eggdrop what channels you want it to monitor, from those channels it lists all the UNIQUE users (for example, if I`m on #a and on #b it will count me only once).

You will also input to the eggdrop what is the "home channel" for example, #EPL, and then it will calculate in percentage how many users are on #EPL compared to its target audience (the list of channels you inputed into the eggdrop that you want it to monitor)

I.E.

<BOT> #EPL reaches 34.1% (106/311) of its target audience.

Another feature added to the script would be that the eggdrop announces a new high percentage and when the previous one was reached

<BOT> A new high percentage was reached! 50% (101/202), Last peak reached was 34.1% (106/311) 5 days ago.

And of course a trigger to see the current high peak.

!Audience

<Bot> Current high peak is 50% (101/202) and was reached 25 seconds ago. (or when it comes to a few days, it will declare how many days ago)


Please help,

Thanks.
Idling at #Football, Quakenet.
d
doggo
Halfop
Posts: 97
Joined: Tue Jan 05, 2010 7:53 am
Contact:

Post by doggo »

Code: Select all

# To enable peak tracking for a channel:
#   .chanset #channel +peak
# !record public command.




setudef flag peak

bind join - * join:peak
proc join:peak {nick host hand chan} {
	if {(([lsearch -exact [channel info $chan] {+peak}] != -1) && ([set curnum [llength [chanlist $chan -b]]] > [set lastmax [lindex [set peak [getpeak $chan]] 0]]))} {
		puthelp "PRIVMSG $chan :New Record $curnum users !!  Last time i saw this many n00bs was [timeago [lindex $peak 1]] ago."
		setpeak $chan $curnum [clock seconds]
	}
}


proc getpeak {chan} { global peak
	if {[info exists peak([set chan [string tolower $chan]])]} {
		set peak($chan)
	} elseif {[file readable "peak.$chan.txt"]} {
		if {[gets [set fid [open "peak.$chan.txt" {RDONLY}]] peak($chan)] < 9} { set peak($chan) [list 0 [clock seconds]] }
		close $fid
		set peak($chan)
	} else {
		set peak($chan) [list [llength [chanlist $chan -b]] [clock seconds]]
	}
}


proc setpeak {chan curnum unixtime} { global peak
	set chan [string tolower $chan]
	puts [set fid [open "peak.$chan.txt" {WRONLY CREAT}]] [set peak($chan) [list $curnum $unixtime]]
	close $fid
}


bind pub -|- !record pub:peak
proc pub:peak {nick host hand chan arg} {
	if {[lsearch -exact [channel info $chan] {+peak}] != -1} {
		puthelp "PRIVMSG $chan :Current Record: [lindex [set peak [getpeak $chan]] 0] users, [timeago [lindex $peak 1]] ago."
	} elseif {[matchattr $hand n|n $chan]} { channel set $chan +peak
		puthelp "PRIVMSG $chan :Peak is now enabled for this channel.  To disable again, use: .chanset $chan -peak"
		savechannels
	}
	return 1
}


proc timeago {lasttime} {
	set totalyear [expr [clock seconds] - $lasttime]
	if {$totalyear >= 31536000} {
		set yearsfull [expr $totalyear/31536000]
		set years [expr int($yearsfull)]
		set yearssub [expr 31536000*$years]
		set totalday [expr $totalyear - $yearssub]
	}
	if {$totalyear < 31536000} {
		set totalday $totalyear
		set years 0
	}
	if {$totalday >= 86400} {
		set daysfull [expr $totalday/86400]
		set days [expr int($daysfull)]
		set dayssub [expr 86400*$days]
		set totalhour 0
	}
	if {$totalday < 86400} {
		set totalhour $totalday
		set days 0
	}
	if {$totalhour >= 3600} {
		set hoursfull [expr $totalhour/3600]
		set hours [expr int($hoursfull)]
		set hourssub [expr 3600*$hours]
		set totalmin [expr $totalhour - $hourssub]
		if {$totalhour >= 14400} { set totalmin 0 }
	}
	if {$totalhour < 3600} {
		set totalmin $totalhour
		set hours 0
	}
	if {$totalmin > 60} {
		set minsfull [expr $totalmin/60]
		set mins [expr int($minsfull)]
		set minssub [expr 60*$mins]
		set secs 0
	}
	if {$totalmin < 60} {
		set secs $totalmin
		set mins 0
	}
	if {$years < 1} {set yearstext ""} elseif {$years == 1} {set yearstext "$years year, "} {set yearstext "$years years, "}
	if {$days < 1} {set daystext ""} elseif {$days == 1} {set daystext "$days day, "} {set daystext "$days days, "}
	if {$hours < 1} {set hourstext ""} elseif {$hours == 1} {set hourstext "$hours hour, "} {set hourstext "$hours hours, "}
	if {$mins < 1} {set minstext ""} elseif {$mins == 1} {set minstext "$mins minute"} {set minstext "$mins minutes"}
	if {$secs < 1} {set secstext ""} elseif {$secs == 1} {set secstext "$secs second"} {set secstext "$secs seconds"}
	string trimright "$yearstext$daystext$hourstext$minstext$secstext" {, }
}

putlog "peak"
im not the author but this work well and im sure you could mod it to watr you want....
Post Reply