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.

Timer wont go on

Old posts that have not been replied to for several years.
Locked
e
exs-n0s
Voice
Posts: 9
Joined: Sat Feb 21, 2004 9:00 pm

Timer wont go on

Post by exs-n0s »

#The script checks the mysql db every 5 minutes. The problem is that the script only checks the db after I rehash the bot. But afterwards, it doesnt parse anymore, unless you rehash the bot. For some odd reason, the timer doesn't work. Some help would be appreciated. Thanks

Code: Select all

set debug 0
set ver "1.1"
set dbhost "_host_"
set dbuser "_user_"
set dbpass "_pass_"
set dbname "_name_"
set timeoff 1141
set date [clock seconds]
set estdate [expr $date - $timeoff]
set lastdate [expr $estdate - 3600]

timer 5 checkdb

proc checkdb { } {	
	global dbhost dbuser dbpass dbname ver debug lastdate
	set dbconnect [mysqlconnect -host $dbhost -user $dbuser -password $dbpass]
	mysqluse $dbconnect $dbname
	if { [mysqlstate $dbconnect -numeric] == 0 } {
		putlog "Could not connect to $dbhost (Unlooping script) -- Forum IRC Notifier $ver"
		mysqlclose $dbconnect
		return 0
	} else {
		if { $debug == 1 } {
			putlog "Connected to $dbhost -- Forum IRC Notifier $ver"
		}
		putlog "#Topic Report# Parsing"
		set sql "SELECT * FROM ibf_topics WHERE start_date > $lastdate ORDER BY start_date DESC"
		set numrows [mysqlsel $dbconnect $sql]
		if { $numrows != 0 } {
			for { set i 0 } { $i < $numrows } { incr i } {
				set res [mysqlnext $dbconnect]
				set topicid [lindex $res 0]
				set topic [lindex $res 1]
				set poster [lindex $res 10]
				set lastdate [lindex $res 6]	
				set link "http://www.teamexcess.net/forums/index.php?showtopic=$topicid"
				putserv "PRIVMSG #excess :\002New Excess.ca Forum Post:\002 $topic"
				putserv "PRIVMSG #excess :\002Link:\002 $link - \002By:\002 $poster"
			}
		}
		mysqlclose $dbconnect
		return 0
	}
}
User avatar
strikelight
Owner
Posts: 708
Joined: Mon Oct 07, 2002 10:39 am
Contact:

Post by strikelight »

timer only calls a proc once.. It is not like mirc's timer command.

To have a proc repeatedly called you need to have the proc use a timer call on itself, something like:

Code: Select all

timer 5 yourproc
proc yourproc {} {
 ...
 timer 5 yourproc
}
Also, to prevent multiple timers from calling the proc on rehash, you should change the first timer call to something like:

Code: Select all

if {![info exists yourtimercheck]} {
  set yourtimercheck [timer 5 yourproc]
}
Locked