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.

auto post advert

Help for those learning Tcl or writing their own scripts.
Post Reply
F
Freakazoid
Voice
Posts: 11
Joined: Sun Jul 31, 2005 12:38 pm

auto post advert

Post by Freakazoid »

Code: Select all

variable sql
variable libMySQLTcl "/usr/local/lib/mysqltcl-3.03/libmysqltcl3.03.so" 


# SQL info
set sql(host) "localhost"
set sql(user) ""
set sql(pass) ""
set sql(db) ""
set sql(port) ""

## END CONF ##

set channel "#eTicker"
set time 30
if {[string compare [string index $time 0] "!"] == 0} { set timer [string range $time 1 end] } { set timer [expr $time * 60] }
if {[lsearch -glob [utimers] "* go *"] == -1} { utimer $timer go }
proc go {} { 
   global sql libMySQLTcl
   set sql(handle) [mysqlconnect -host $sql(host) -user $sql(user) -password $sql(pass) -db $sql(db) -port $sql(port)]
   set query [::mysql::query $sql(handle) "SELECT werbung FROM advert ORDER BY DESC LIMIT 1 "]
   while {[set row [::mysql::fetch $query]] != ""} {
   set werbung [lindex $row 0]
 global channel time text timer
foreach chan $channel {
 putserv "PRIVMSG $chan :$werbung" 
 }
   }
::mysql::endquery $query
mysqlclose $sql(handle)
}
if {[lsearch -glob [utimers] "* go *"] == -1} { utimer $timer go }

why does work this script :(
1 time it will be work after rehash no more function from it


mfg freak
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Properly indenting the code would reveal that you don't call either timer or utimer within the proc, you also do not use the "time" binding..
Obviously, you will only execute "go" once...

Most likely, you've misunderstood the use of timer and utimer...
These allow you to delay the execution of some code, it will not repeat the execution multiple times...
NML_375
F
Freakazoid
Voice
Posts: 11
Joined: Sun Jul 31, 2005 12:38 pm

Post by Freakazoid »

oki !
F
Freakazoid
Voice
Posts: 11
Joined: Sun Jul 31, 2005 12:38 pm

Post by Freakazoid »

i lost a line in the code :D
now it works ;)
<<< pinky is ;)
from pinky and the brain
Post Reply