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.

sugestion

Old posts that have not been replied to for several years.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

sugestion

Post by caesar »

I have an database (actualy an .txt file with some links in it) and I vote them once per 24 hours. It's from an online game to help my alliance. I need an sugestion on how should I mark them when I vote one link and then to get from there only the ones that have passed the 24 hours limit. Also, how should I save the votes, in an array and then after 15 minutes or something in the file or directly to it? Any recomandations?

I've stucked at the hours part, since there is no 24:00 hour only an 00:00 one, so an 01:00 will screw my thing down. I was thinging in calculating the difference betwen this two like 23:00 - the time it got voted and add 1 hour to the result. I'm kinda clue less, no ideeas from where to start.. :mrgreen: :roll:
Once the game is over, the king and the pawn go back in the same box.
User avatar
GodOfSuicide
Master
Posts: 463
Joined: Mon Jun 17, 2002 8:00 pm
Location: Austria

Post by GodOfSuicide »

what do you mean by vote ? you rate them or something like that ?

btw, for the time : add [unixtime] output infront of the URL when you save it for a textfile, when you check you watch if it's older than 24h -> delete
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Vote as in click the link :)
duration [unixtime] = 34 years 1 day 22 hours 6 minutes 59 seconds
How the bloddy hell will that help me? Also, this 24 hours limit must be done automaticly by the eggdrop, not by me :)
Once the game is over, the king and the pawn go back in the same box.
User avatar
GodOfSuicide
Master
Posts: 463
Joined: Mon Jun 17, 2002 8:00 pm
Location: Austria

Post by GodOfSuicide »

when you add the url to the database add the current [unixtime] (NOT duration) in front / after it
then you generate a timer that checks how much time passed between the current [unixtime] and the var you have in front / after your url.
so you can check when it's been added and take the consequences
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Umm.. like comparing if the unixtime from the link is let's say 34 years 1 day 22 hours 6 minutes 59 seconds and my current unixtime is 34 years 2 days 22 hours 6 minutes 59 then it should be working fine, I guess. Neat. Thanks for the lil tip. Also, no need for timers. Just an 15 minutes check or even an check on the spot when I do clicks and want to see thouse that have passed the 24 hours limit. Thank you. :)
Once the game is over, the king and the pawn go back in the same box.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Code: Select all

proc bla {} {
set list [split [read [set f [open "koc.db" r]]][close $f] \n]
foreach bla $list {
putlog [duration [expr [unixtime] - [lindex $bla 1]]]
}
}
What the bloddy hell should I do now to get ridd of the annoyng "Tcl error: syntax error in expression "1072394717 - ": premature end of expression" msg? :o :x
Once the game is over, the king and the pawn go back in the same box.
User avatar
Papillon
Owner
Posts: 724
Joined: Fri Feb 15, 2002 8:00 pm
Location: *.no

Post by Papillon »

that error means that there is no 2nd element in your list
are you sure $bla is a list?
do a check on what the $list/$bla contains
Elen sila lúmenn' omentielvo
User avatar
GodOfSuicide
Master
Posts: 463
Joined: Mon Jun 17, 2002 8:00 pm
Location: Austria

Post by GodOfSuicide »

caesar wrote:Umm.. like comparing if the unixtime from the link is let's say 34 years 1 day 22 hours 6 minutes 59 seconds and my current unixtime is 34 years 2 days 22 hours 6 minutes 59 then it should be working fine, I guess.
did you listen ? I said NOT to use duration...
take the current [unixtime] (NOT DURATION), substract the old one from it

that looks some kinda like this:
current time - old time = x
1072443286 - 1072443256 = 30

if x >= 86400 -> older than 24h
(correct me if the value is wrong, thats 60 * 60 * 24)
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

GodOfSuicide : Well.. calculating the duration betwen them or doing what you've said seems to me to be the same thing, at least for me dose, and mine looks a lot easier. :)

Damn.. /me slaps itself.. I wonder how the heck did I forgot to add the [unixtime] thing there.. umm.. *problem* fixed. :) :oops:
Once the game is over, the king and the pawn go back in the same box.
User avatar
GodOfSuicide
Master
Posts: 463
Joined: Mon Jun 17, 2002 8:00 pm
Location: Austria

Post by GodOfSuicide »

hehe

let's have a look at it when it's finished, ok ?
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

"sugestion"? I think this post might have to be deleted ;)
User avatar
arcane
Master
Posts: 280
Joined: Thu Jan 30, 2003 9:18 am
Location: Germany
Contact:

Post by arcane »

stdragon wrote:"sugestion"? I think this post might have to be deleted ;)
yeah, it has to be "suggestion" :mrgreen:
aVote page back online!
Check out the most popular voting script for eggdrop bots.

Join the metal tavern!
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Heh.. I was hungry and I've eat an letter.. :D

Edit: Now an "open" problem. Seems that it adds an blank line after adding the link in the file, and again cos of that the "premature end of expression" pops-out his ugly face :) .. so, any suggestions on how should I get ridd of the blank line?

Code: Select all

proc my:click {nick uhost hand chan text} {
  set list [split [read [set f [open "koc.db" r]]][close $f] \n] 
  foreach bla $list { 
    if {[expr [unixtime] - [lindex $bla 1]] >= 86400} {
      putserv "PRIVMSG $chan :[lindex $bla 0]"
    } 
  }
}
As you can see I've folowed your advice GodOfSuicide, cos yours at another close look seems a lot easier that what I had in mind. :)
Once the game is over, the king and the pawn go back in the same box.
User avatar
GodOfSuicide
Master
Posts: 463
Joined: Mon Jun 17, 2002 8:00 pm
Location: Austria

Post by GodOfSuicide »

caesar wrote:Heh.. I was hungry and I've eat an letter.. :D
i'd rather delete it for poor subject line but ok... :P
Edit: Now an "open" problem. Seems that it adds an blank line after adding the link in the file
that proc doesnt add anything to the file, it's just reading from it.
if you have got blank lines just check for them..like "are there 2 words ?" "is the line != \n ?" etc (i'm sorry i cannot provide more help cos i dont see the real problem)
As you can see I've folowed your advice GodOfSuicide, cos yours at another close look seems a lot easier that what I had in mind. :)
you're welcome
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

The link is added "normaly" in the file like:

Code: Select all

set f [open "koc.db" a]
puts $f "[lindex [split $text] 0] [unixtime]" 
close $f
Yes I know, that proc just reads from that file and it's suposed to not read the blank ones but it dose..
Once the game is over, the king and the pawn go back in the same box.
Locked