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.

how does this tcl work?

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
g
geek
Halfop
Posts: 47
Joined: Fri Oct 24, 2008 6:07 am

how does this tcl work?

Post by geek »

I try this tcl:
https://github.com/starlilyth/IRC-Eggdr ... rma4.4.tcl

It works good

but I looking at the code and I don't understand what is the needed of modtime column in the db and the use of xtime, ytime, yytime, etc in proc karmaupdate


what are they for?
User avatar
CrazyCat
Revered One
Posts: 1236
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

They are used to increase or decrease the karma based on the time it has been set.

Here is the code with my comments:

Code: Select all

# $kutime is the actual timestamp
# the modification time (modtime) will be set to $kutime when a record is updated
set kutime [clock seconds]

# $xtime is 90 days before
set xtime [expr $kutime - (90 * 86400)]

# delete all karmas which are locked and with a small value (between -1 and 1) and older than 90 days
kdb eval {DELETE FROM lkarma WHERE modtime < $xtime AND karma between -1 and 1 and locked='N'}

# decrease the value of positives karma and increase the value of negative karma
# if they are between 2 and 22 (positive or negative) and older than 90 days
kdb eval {UPDATE lkarma SET karma=karma-1, modtime=$kutime WHERE modtime < $xtime AND karma between 2 and 22 AND locked='N'}
kdb eval {UPDATE lkarma SET karma=karma+1, modtime=$kutime WHERE modtime < $xtime AND karma between -22 and -2 AND locked='N'}

# $ytime is 30 days before
set ytime [expr $kutime - (30 * 86400)]

# decrease the value of positives karma and increase the value of negative karma
# if they are between 23 and 54 (positive or negative) and older than 30 days
kdb eval {UPDATE lkarma SET karma=karma-1, modtime=$kutime WHERE modtime < $ytime AND karma between 23 and 54 AND locked='N'}
kdb eval {UPDATE lkarma SET karma=karma+1, modtime=$kutime WHERE modtime < $ytime AND karma between -54 and -23 AND locked='N'}

#... and doing the same with diffrent delays and karma values
## older than 7days and between 55 and 80
## older than 2 days and between 81 and 120
## older than 1 day and between 121 and 540
## older than 8 hours (1 day / 3) and between 541 and 959
## older than 4h48 (1 day / 5) and higher than 960
The goal seems to be to make the karma going to 0 when it has not been modified for a time. Lesser (positive or negative) is your karma and slower it will decrease (tend to 0)
g
geek
Halfop
Posts: 47
Joined: Fri Oct 24, 2008 6:07 am

Post by geek »

CrazyCat wrote:The goal seems to be to make the karma going to 0 when it has not been modified for a time. Lesser (positive or negative) is your karma and slower it will decrease (tend to 0)
now I understand

thanks man!
Post Reply