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.

Timers and additions

Help for those learning Tcl or writing their own scripts.
Post Reply
X
X-Ception
Voice
Posts: 37
Joined: Fri May 20, 2005 3:12 am
Location: Earth
Contact:

Timers and additions

Post by X-Ception »

I'm wanting to create a script thats works on the basis of start and stop on a per user level with addition of time...

for example:
<nick> !login
<bot> Nick you're now logged in
<nick2> !login
<bot> Nick2 you're now logged in
While logged in a timer or similar is running basically counting mins which are written to a file
<nick2> !logout
<bot> Nick2 you're now logged out
in the file it should say similar to:

Code: Select all

Nick1 has been logged in for 0 hours 10 mins 23 seconds 
Seconds not really needed but for hours and mins its a must, this file then must restart once every 7 days ( renaming the old one to log.lastweek ..whatever )

I'm very uncomfy with timers and ive not worked too often if ever with additions in this manner could someone give me some tips, a starting point or even better point me to one that does the above already :P ( never know huh ? )

note
The basis of login is NOT based on bots userlist but users on a specific channel - anyone on said channel must be able to login/out

preferbly with a specific flag being able to log users out that failed to log themselves out
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

No need for timers. Just use the [unixtime] when they login and the difference from NOW in unixtime and the last unixtime recorded:

Code: Select all

set now [unixtime]
set difference [expr [unixtime - $now]]
set duration [duration $difference]
Also, if all of your users use a specific credentials then I would go for XTRA fields in the userfile for each user in particular.

Code: Select all

setuser $hand XTRA LAST [unixtime]
and to see the actual online time use something like:

Code: Select all

set last [getuser $hand XTRA LAST]
set difference [expr [unixtime - $last]]
set duration [duration $difference]
Once the game is over, the king and the pawn go back in the same box.
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Re: Timers and additions

Post by demond »

X-Ception wrote: The basis of login is NOT based on bots userlist but users on a specific channel - anyone on said channel must be able to login/out
then you need to develop an authorization system first; or by "login" you mean simply recording current time for the user issued that command?
connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use

Code: Select all

 tag when posting logs, code
w
wiz(andrew)
Voice
Posts: 5
Joined: Fri Sep 01, 2006 7:47 am

Post by wiz(andrew) »

Code: Select all

if {[onchan $nick $chan] } {...}
?
X
X-Ception
Voice
Posts: 37
Joined: Fri May 20, 2005 3:12 am
Location: Earth
Contact:

Re: Timers and additions

Post by X-Ception »

demond wrote: by "login" you mean simply recording current time for the user issued that command?
yup
X
X-Ception
Voice
Posts: 37
Joined: Fri May 20, 2005 3:12 am
Location: Earth
Contact:

Post by X-Ception »

Well the reason i thought the use of timers would be needed was it needs to be started and stoped by the user and then recorded to a text file/database file of some format so the administration can see WHO is actually putting in what amount of times on a per week basis, but none of the users will be on the userlist
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

You should be able to use most of caesar's script. Just have to use variables to store "logon-time", rather than the user database fields.. (arrays with nicks as index comes to mind)

Only use for timers that I could possibly see, would be some automated logout-feature. Although this would probably be easier to implement without timers aswell.

As for writing to the logfile, I'd either write on "!logout", or on a regular basis using "bind time". Log rotation would be implemented using "bind time" or "bind evnt".
NML_375
Post Reply