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.

Op time counter

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
C
Cr0ntab
Voice
Posts: 22
Joined: Fri Mar 26, 2010 11:31 am

Op time counter

Post by Cr0ntab »

Hello. I would like to request a script but i dont know how easy it is to make.

The script i need is one that counts how many hours per day/week each of the users that match the +C flag ops in a channel. To make it more clear:

All the ops in my channel let's say #channel have the global +C flag on the bot. I want the script to count how many hours each person has opped in one day and in the week. As for how the bot will give me the hours can it create a webpage or let me know on request by a command i send in pvt?

For example if the report is given by command i type in pvt: !optimes and the bot will respond:

Oper1: Opped today: 1hr 23mins Opped this week: 14hrs 23mins.
Oper2: Opped today: 1hr 23mins Opped this week: 14hrs 23mins.

But please make it look ONLY #channel!!! cause bot sits in many chans irrelevant to #channel or perhaps the ops channel.

I appreciate if anyone takes the time to deal with this request
User avatar
Madalin
Master
Posts: 310
Joined: Fri Jun 24, 2005 11:36 am
Location: Constanta, Romania
Contact:

Post by Madalin »

Modifyed this version of mine to look only on channels where +timespent is set and the users have +C channel flag

Code: Select all

#### ++++ Author: MadaliN <madalinmen28@yahoo.com>
### +++ Website: www.Ascenture.ro
## +++ TCL Name: TimeSpent
# +++ Version: 2.0
#
# Commands:
#   /msg BOTNICK timespent activate <$chan>       	(local or global owner)
#   /msg BOTNICK timespent deactivate <$chan>		(local or global owner)
#   /msg BOTNICK timespent <$nickname> <$chan>		(local or global owner)
#

####
# +++ Created: 6/8/2013
####

bind MSGM - * timespent:msg

setudef flag timespent

proc egghelp:timespent {min hour day month year} {
	global timespent announce noa

	set list ""
	foreach chan [channels] {
		if {[channel get $chan timespent]} {
			foreach u [chanlist $chan] {
				if {[matchattr $u -|C $chan] && [isop $u $chan]} {
					putlog "Found \002$u"
					set host [lindex [split [getchanhost $u $chan] @] 1]

					if {![info exists timespent($chan,$host)]} {
						set timespent($chan,$host) "60 $u"
						timespent:save
					} else {
						set timespent($chan,$host) "[expr [lindex [split $timespent($chan,$host)] 0] + 60] $u"
						timespent:save
					}
				}
			}
		}
	}
}

proc timespent:msg {nick uhost hand arg} {
	global timespent

	if {[lindex [split $arg] 2] != ""} {
		set chan [lindex [split $arg] 2]
		set host [lindex [split [getchanhost [lindex [split $arg] 1] $chan] @] 1]
	}

	switch -exact -- [lindex [split $arg] 0] {
		timespent {
			switch -exact -- [lindex [split $arg] 1] {
				activate {
					if {[matchattr $hand n]} {
						channel set $chan +timespent

						putserv "PRIVMSG $chan :\002$nick\002 - TIMESPENT script \00312activated\003 succesfully"
					}
				}
				deactivate {
					if {[matchattr $hand n]} {
						channel set $chan -timespent

						putserv "PRIVMSG $chan :\002$nick\002 - TIMESPENT script \00304deactivated\003 succesfully"
					}
				}
				reset {
					if {[matchattr $hand n]} {
						unset -nocomplain timespent

						putserv "PRIVMSG $nick :\002$nick\002 - Timespent with @ was RESET for everyone"
					}
				}
				default {
					if {[matchattr $hand n]} {
						if {[string match -nocase "#*" [lindex [split $arg] 2]]} {
							if {![info exists timespent([lindex [split $arg] 2],$host)]} {
								putserv "PRIVMSG $nick :\002$nick\002 - Nickname \00303[lindex [split $arg] 1]\003 has no info on \00312[lindex [split $arg] 2]"
							} else {
								putserv "PRIVMSG $nick :\002$nick\002 - Nickname \00303[lindex [split $arg] 1]\003 idled with @ on \00312[lindex [split $arg] 2]\003 for \00303[duration [lindex [split $timespent([lindex [split $arg] 2],$host)] 0]]"
							}
						}
					}
				}
			}
		}
	}
}

proc timespent:save {} {
	global timespent

	set ofile [open timespent w]
	puts $ofile "array set timespent [list [array get timespent]]"
	close $ofile
}

catch {source timespent}

putlog "+++ Succesfully loaded: \00312Timpespent TCL Script"
Original script can be found at http://forum.egghelp.org/viewtopic.php?t=19314
Post Reply