An i would like it to announce when a user joins my channel. on quakenet, it announce the username and rank_title (phpbb2 forum)
1. the users are stored in phpbb_users -> username ($user_id)
2. rank title is in phpbb_ranks -> rank_title ($rank_id)
[EDIT]
I have tryed to set the table according, to the old owns in the script but it gives a error : Tcl error [join:Support-Forum.dk]: can't read "username": no such variable [/EDIT]
package require mysqltcl
setudef flag joinmsg
bind join - * join:Support-Forum.dk
bind rejn - * join:Support-Forum.dk
##################
### Mysql path ###
##################
# SQL info
set sql(host) "xxxxx"
set sql(user) "xxxxx"
set sql(pass) "xxxxx"
set sql(db) "xxxxxxx"
set sql(port) "3306"
##################
### Mysql path ###
##################
if {![info exists db_handle] } {
set db_handle [mysqlconnect -host $sql(host) -user $sql(user) -password $sql(pass) -db $sql(db) -port $sql(port)]
}
###########################################
### Greeting MSG When User Join channel ###
###########################################
proc bt.join.rank_title { chan username rank_title} {
if {[channel get $chan joinmsg]} {
switch $rank_title {
### The number is the number of the class on the site
### "return 0" means no msg for that class
"1" {putserv "PRIVMSG $chan :7Velkommen Til 4\:\:\:2 $username 4\:\:\:9 14 $rank_title"}
"default" {set class "Not Found" }
}
}
}
#################
### Join Proc ###
#################
proc join:Support-Forum.dk {nick host hand chan} {
global botnick db_handle
if {$nick != $botnick} {
# if {[mysqlping $db_handle] != 1} {
# putserv "notice $nick : The connection to the mysql server has been lost."
# return 0
# }
set sqlnick "SELECT user_id FROM phpbb_users WHERE nick='[mysqlescape $username]'"
set resultusername [mysqlquery $db_handle $sqlusername]
set nicki 0
while {[set record [mysqlnext $resultusername]] != ""} {
set user_id [lindex $record 0]
incr nicki
}
if { $nicki == 0 } { return 0 }
if { $user_id == "" } { return 0 }
set sql "SELECT rank_title FROM phpbb_ranks WHERE id='[mysqlescape $user_id]'"
set result [mysqlquery $db_handle $sql]
set i 0
while {[set record [mysqlnext $result]] != ""} {
set username [lindex $record 0];
set rank_title [lindex $record 1];
}
set sql "SELECT rank_title FROM phpbb_ranks WHERE id='[mysqlescape $user_id]'"
set result [mysqlquery $db_handle $sql]
set i 0
while {[set record [mysqlnext $result]] != ""} {
set username [lindex $record 0];
set rank_title [lindex $record 1];
}
mysqlendquery $result
bt.join.rank_title $chan $nick $rank_title
}
}
proc join:Support-Forum.dk {nick host hand chan} {
global botnick db_handle
if {$nick != $botnick} {
# if {[mysqlping $db_handle] != 1} {
# putserv "notice $nick : The connection to the mysql server has been lost."
# return 0
# }
set sqlnick "SELECT user_id FROM phpbb_users WHERE nick='[mysqlescape $username]'"
set resultusername [mysqlquery $db_handle $sqlusername]
Here you can clearly see the problem. $nick is joining, yet you refer to this in your [mysqlescape] as $username. Change that to $nick. You also set sqlnick as your query. Yet when making the [mysqlquery] you refer to it as $sqlusername. Change it to $sqlnick. You need to keep your variables straight is the problem.
##################
### Mysql path ###
##################
if {![info exists db_handle] } {
set db_handle [mysqlconnect -host $sql(host) -user $sql(user) -password $sql(pass) -db $sql(db) -port $sql(port)]
}
###########################################
### Greeting MSG When User Join channel ###
###########################################
proc bt.join.rank_title { chan nick rank_title} {
if {[channel get $chan joinmsg]} {
switch $rank_title {
### The number is the number of the class on the site
### "return 0" means no msg for that class
"1" {putserv "PRIVMSG $chan :7Velkommen Til 4\:\:\:2 $username 4\:\:\:9 14 $rank_title"}
"default" {set rank_title "Not Found" }
}
}
}
#################
### Join Proc ###
#################
proc join:support {nick host hand chan} {
global botnick db_handle
if {$nick != $botnick} {
# if {[mysqlping $db_handle] != 1} {
# putserv "notice $nick : The connection to the mysql server has been lost."
# return 0
# }
set sqlnick "SELECT user_id FROM phpbb_users WHERE username='[mysqlescape nick]'"
set resultusername [mysqlquery $db_handle $sqlnick]
set nicki 0
while {[set record [mysqlnext $resultusername]] != ""} {
set user_id [lindex $record 0]
incr nicki
}
if { $nick == 0 } { return 0 }
if { $user_id == "" } { return 0 }
set sql "SELECT rank_title FROM phpbb_ranks WHERE user_id='[mysqlescape $user_id]'"
set result [mysqlquery $db_handle $sql]
set i 0
while {[set record [mysqlnext $result]] != ""} {
set nick [lindex $record 0];
set rank_title [lindex $record 1];
}
set sql "SELECT rank_title FROM phpbb_ranks WHERE id='[mysqlescape $user_id]'"
set result [mysqlquery $db_handle $sql]
set i 0
while {[set record [mysqlnext $result]] != ""} {
set nick [lindex $record 0];
set rank_title [lindex $record 1];
}
mysqlendquery $result
bt.join.rank_title $chan $nick $rank_title
}
}
I get this error now : Tcl error [join:support]: invalid command name "join:support"[/code]