egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

how does this tcl work?

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
geek
Voice


Joined: 24 Oct 2008
Posts: 37

PostPosted: Thu Feb 11, 2021 4:48 am    Post subject: how does this tcl work? Reply with quote

I try this tcl:
https://github.com/starlilyth/IRC-Eggdrop-TCL/blob/master/lilykarma4.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?
Back to top
View user's profile Send private message
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1032
Location: France

PostPosted: Fri Feb 12, 2021 8:17 am    Post subject: Reply with quote

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:

# $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)
_________________
https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
geek
Voice


Joined: 24 Oct 2008
Posts: 37

PostPosted: Fri Feb 12, 2021 1:35 pm    Post subject: Reply with quote

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!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber