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 

[solved] best way to apprach this

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
doggo
Halfop


Joined: 05 Jan 2010
Posts: 97

PostPosted: Fri Oct 15, 2010 4:24 am    Post subject: [solved] best way to apprach this Reply with quote

grabs a added time from a db in unix time

but im having a right time getting it to return what i want in channel :/

heres the proc


Code:
namespace eval mp3_time_add {
proc get_mp3_time {nick host hand chan text} {

   set time_pred ""
   set add_time_mp3 [::mysql::connect -host $reqs::sett::db_host -port $reqs::sett::db_port -user $reqs::sett::db_user -password $reqs::sett::db_pass -db $reqs::sett::db_pre_name];
   set added_mp3 [::mysql::sel $mp3_pre "SELECT $reqs::sett::db_pre_time FROM $reqs::sett::db_pre_table where $reqs::sett::db_pre_rls = '$add_rls'" -flatlist];
   ::mysql::endquery $add_time_mp3
   ::mysql::close $add_time_mp3
   if {$added_mp3 == ""} {set time_pred "unknown"} else {
   set now [unixtime]
   incr now -$pre_mp3
   set time_pred [duration $now]
       regsub -nocase {seconds} $time_pred "s" time_pred
       regsub -nocase {second} $time_pred "s" time_pred
       regsub -nocase {minutes} $time_pred "m" time_pred
       regsub -nocase {minute} $time_pred "m" time_pred
       regsub -nocase {hours} $time_pred "h" time_pred
       regsub -nocase {hour} $time_pred "h" time_pred
       regsub -nocase {days} $time_pred "d" time_pred
       regsub -nocase {day} $time_pred "d" time_pred
       regsub -nocase {weeks} $time_pred "w" time_pred
       regsub -nocase {week} $time_pred "w" time_pred
      regsub -nocase {months} $time_pred "m" time_pred
       regsub -nocase {month} $time_pred "m" time_pred
       regsub -nocase {years} $time_pred "y" time_pred
       regsub -nocase {year} $time_pred "y" time_pred
   #regsub -all { |\*} $time_pred {} time_pred
   putquick "PRIVMSG $reqs::sett::add_chan :$time_pred"
   }

#END NAMESPACE mp3_time_add
}




currently returns

[Pred 1 d 12 h 56 m 59 s ago]

if i use the regsub to remove the spaces it returns

[Pred 1d13h27m8s ago]

but i realy realy want it to return like this

[Pred 1d 12h 56m 59s ago]

if anyone has any better way to achieve this id be most interested, thanks Very Happy
_________________
NON geeky!! http://gotcode4u.com/
Back to top
View user's profile Send private message Visit poster's website
doggo
Halfop


Joined: 05 Jan 2010
Posts: 97

PostPosted: Fri Oct 15, 2010 6:25 am    Post subject: Reply with quote

Code:
namespace eval mp3_time_add {
proc get_mp3_time {nick host hand chan text} {

   set time_pre ""
   set add_time_mp3 [::mysql::connect -host $reqs::sett::db_host -port $reqs::sett::db_port -user $reqs::sett::db_user -password $reqs::sett::db_pass -db $reqs::sett::db_pre_name];
   set added_mp3 [::mysql::sel $mp3_pre "SELECT $reqs::sett::db_pre_time FROM $reqs::sett::db_pre_table where $reqs::sett::db_pre_rls = '$add_rls'" -flatlist];
   ::mysql::endquery $add_time_mp3
   ::mysql::close $add_time_mp3
   if {$added_mp3 == ""} {set time_pred "unknown"} else {
   set now [unixtime]
   incr now -$pre_mp3
   set time_pre [duration $now]
       regsub -nocase -all -- { seconds|seconds} $time_pre "s" time_pre
       regsub -nocase -all -- { minutes|minutes} $time_pre "m" time_pre
       regsub -nocase -all -- { hours|hours} $time_pre "h" time_pre
       regsub -nocase -all -- { days|days} $time_pre "d" time_pre
       regsub -nocase -all -- { weeks|weeks} $time_pre "w" time_pre
       regsub -nocase -all -- { months|months} $time_pre "m" time_pre
       regsub -nocase -all -- { years|years} $time_pre "y" time_pre
   putquick "PRIVMSG $reqs::sett::add_chan :$time_pred"
   }

#END NAMESPACE mp3_time_add
}


i just needed to read more Very Happy

returns


Code:
[Pred 27y 50w 5d 22m 46s ago]


just how i wanted
_________________
NON geeky!! http://gotcode4u.com/
Back to top
View user's profile Send private message Visit poster's website
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Fri Oct 15, 2010 6:46 pm    Post subject: Re: [solved] best way to apprach this Reply with quote

Code:
namespace eval mp3_time_add {
proc get_mp3_time {nick host hand chan text} {

   set add_time_mp3 [::mysql::connect -host $reqs::sett::db_host -port $reqs::sett::db_port -user $reqs::sett::db_user -password $reqs::sett::db_pass -db $reqs::sett::db_pre_name];
   set added_mp3 [::mysql::sel $mp3_pre "SELECT $reqs::sett::db_pre_time FROM $reqs::sett::db_pre_table where $reqs::sett::db_pre_rls = '$add_rls'" -flatlist];
   ::mysql::endquery $add_time_mp3
   ::mysql::close $add_time_mp3
   if {![string length $added_mp3]} {set time_pred "unknown"} else {
      set now [unixtime]
      incr now -$pre_mp3
      foreach {val short} [split [duration $now] " "] { append time_pred "$val[string index $short 0] " }
      putquick "PRIVMSG $reqs::sett::add_chan :[string trim $time_pred]"
   }

#END NAMESPACE mp3_time_add
}

_________________
speechles' eggdrop tcl archive
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 -> Scripting Help 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