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.

bind join/part

Help for those learning Tcl or writing their own scripts.
Post Reply
W
WazzaUK
Voice
Posts: 19
Joined: Sun Jul 02, 2006 5:03 pm

bind join/part

Post by WazzaUK »

im trying to set a field in a MYSQL table when users are in a particular channel ('yes' when join, 'no' when part). Join works fine, but part doesnt even seem to call the procedure. Ive gotta be missing something..

Any ideas.....

Code: Select all

load /usr/local/lib/mysqltcl-3.02/libmysqltcl3.02.so
package require mysqltcl
set db_handle [mysqlconnect -host ###.###.###.### -socket /var/lib/mysql/mysql.sock -user <user> -password <password> -db <database>

bind join - "#channel *" join_main
bind part - "#channel *" part_main

proc join_main {nick uhost hand channel} {
global db_handle botnick
  if {$nick==$botnick} {return 0}
  set sql "UPDATE users SET onirc = 'yes' WHERE username = '$nick'"
  putloglev d * "ircstats: executing $sql"
  set result [mysqlexec $db_handle $sql]
  if {$result != 1} {
    putlog "SQL - error"
  } else {
     set id [mysqlinsertid $db_handle]
     puthelp "PRIVMSG $channel :User Online \002$nick\002 added"
  }
}

proc part_main {nick uhost hand channel} {
global db_handle botnick
  if {$nick==$botnick} {return 0}
  set sql "UPDATE users SET onirc = 'no' WHERE username = '$nick'"
  putloglev d * "ircstats: executing $sql"
  set result [mysqlexec $db_handle $sql]
  if {$result != 1} {
    putlog "SQL - Error"
  } else {
     set id [mysqlinsertid $db_handle]
     puthelp "PRIVMSG $channel :User Offline \002$nick\002 removed"
  }
}
W
WazzaUK
Voice
Posts: 19
Joined: Sun Jul 02, 2006 5:03 pm

i see it

Post by WazzaUK »

i forgot a msg param in part procedure
W
WazzaUK
Voice
Posts: 19
Joined: Sun Jul 02, 2006 5:03 pm

Quit / Ping timeout

Post by WazzaUK »

seems that part doesnt cover quit and pingtime out - any ideas???
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Yup, quit is a completely separate (irc) command from part..
Hence it got its own binding, "sign":
bind sign <flags> <mask> <proc>
procname <nick> <user@host> <handle> <channel> <reason>

Description: triggered by a signoff, or possibly by someone who got
netsplit and never returned. The signoff message is the last
argument to the proc. Wildcards can be used in the mask, which is
matched against '#channel nick!user@host'.
NML_375
W
WazzaUK
Voice
Posts: 19
Joined: Sun Jul 02, 2006 5:03 pm

nick change

Post by WazzaUK »

yep sign covered quit/ping timeout

what about nick change - is there a list of these procedures anywhere?

got it lol

bind nick <flags> <mask> <proc> procname <nick> <user@host> <handle> <channel> <newnick>

Stackable
Triggered when someone changes nicknames. Wildcards are allowed. The mask is matched against #channel newnick.
Post Reply