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.

Start automatic and re-execute

Old posts that have not been replied to for several years.
Locked
K
Kato

Start automatic and re-execute

Post by Kato »

Ok, now I have figured out my first Script ( :mrgreen: ). What I now want it to do, is to start once in the channel and then restart the procedure every 5 minutes.

I have tried to merge my script with this instruction

Code: Select all

if {![info exists myproc_running]} {   
    timer 20 myproc                      
    set myproc_running 1                 
  }                                      
                                         
  proc myproc {} {                       
      # your stuff here ...              
      # ...                              
      timer 20 myproc                    
      return 1                           
  }          
But I cannot get it to work. The bot will not start nor reexecute the procedure. I guess I am missing something. Now here is my script, which is currently bound to the trigger .test. Is there a way to remove the trigger, so that the procedure starts automatically for the first time and then reexecute the procedure nicksql every 5 minutes?

Code: Select all

#Ausgabescript

#!/usr/bin/tclsh8.3


bind pub - .test nicksql

proc nicksql {nick uhost hand chan args} {                       
putserv "PRIVMSG $chan :Bot is listening"
set mysql_handler [mysqlconnect -host localhost -port 3306 -user XXX -password XXX -db XXX]
#putserv "PRIVMSG $chan :After Database connect"
mysqlexec $mysql_handler "DELETE FROM irc_online"
foreach nick [chanlist $chan] {
#putserv "PRIVMSG $chan :$nick"
mysqlexec $mysql_handler "INSERT INTO irc_online (Nickname) VALUES ('$nick');"
}
#putserv "PRIVMSG $chan :After Database insert" 
mysqlclose $mysql_handler
}
Many thanks in advance for your support.

Kato
K
Kato

This sucks

Post by Kato »

Any help is really appreciated here.

I have just tried with

Code: Select all

#Ausgabescript

#!/usr/bin/tclsh8.3

package require mysqltcl

timer 1 nicksql 
proc nicksql { nick uhost hand chan args } {
putserv "PRIVMSG $chan :Bot is listening"
set mysql_handler [mysqlconnect -host localhost -port 3306 -user XXX -password XXX -db XXX]
putserv "PRIVMSG $chan :After Database connect"
mysqlexec $mysql_handler "DELETE FROM irc_online"
foreach nick [chanlist $chan] {
putserv "PRIVMSG $chan :$nick"
mysqlexec $mysql_handler "INSERT INTO irc_online (Nickname) VALUES ('$nick');"
}
putserv "PRIVMSG $chan :After Database insert" 
mysqlclose $mysql_handler
timer 1 nicksql
}
And it is not working. When I am doing a bind pub to some textstring, the script works perfectly. Only when I am trying to use the timer/bind time or similiar, the bot won´t do anything in the channel. However, there is no failure message. Maybe someone can help to find a way out of here.

Thanks

Kato
User avatar
Papillon
Owner
Posts: 724
Joined: Fri Feb 15, 2002 8:00 pm
Location: *.no

Post by Papillon »

there is some errors in your code, first of, when calling a proc from a timer or utimer they are beeing executed at once, unless handeled correctly. And when you call the proc, you have to make sure it has the right amount of arguments

Code: Select all

#this is wrong
timer 1 nicksql
#while this would work
timer 1 [list nicksql Papillon *!bla@bla.com Papi #tcl bla]
ofc you're gonna have some problem if you want the $nick and $chan varaibles to be different each time... :wink:
Elen sila lúmenn' omentielvo
Locked