Code: Select all
package require mysqltcl
setudef flag joinmsg
bind join - * join:testarea
bind rejn - * join:testarea
##################
### Mysql path ###
##################
# SQL info
set sql(host) "xxxxxxxxxx"
set sql(user) "xxxxxxxxxx"
set sql(pass) "xxxxxxxxxx"
set sql(db) "xxxxxxxxxx"
set sql(port) "xxxx"
##################
### 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.class { chan nick class} {
if {[channel get $chan joinmsg]} {
switch $class {
### The number is the number of the class on the site
### "return 0" means no msg for that class
"default" {set class "Not Found" }
}
}
}
#################
### Join Proc ###
#################
proc join:testarea {nick host hand chan} {
global botnick db_handle
if {$nick != $botnick} {
if {[mysqlping $db_handle] != 1} {
putserv "PRIVMSG $chan : The connection to the mysql server has been lost."
return 0
}
set sqlnick "SELECT userid FROM joinmsgnicks WHERE nick='[mysqlescape $nick]'"
set resultnick [mysqlquery $db_handle $sqlnick]
set nicki 0
while {[set record [mysqlnext $resultnick]] != ""} {
set userid [lindex $record 0]
incr nicki
}
if { $nicki == 0 } { return 0 }
if { $userid == "" } { return 0 }
set sql "SELECT username, class FROM joinmsgircuser WHERE id='[mysqlescape $userid]'"
set result [mysqlquery $db_handle $sql]
set i 0
while {[set record [mysqlnext $result]] != ""} {
set username [lindex $record 0];
set class [lindex $record 1];
}
set sql "SELECT username, class FROM joinmsgircuser WHERE id='[mysqlescape $userid]'"
set result [mysqlquery $db_handle $sql]
set i 0
while {[set record [mysqlnext $result]] != ""} {
set username [lindex $record 0];
set class [lindex $record 1];
}
mysqlendquery $result
bt.join.class $chan $nick $class
}
}
putlog "Joinmsg"
I want to add the user to the database, without going into the database to add the user all the time...
so something like:
So it outputs :!addmsg NickName Text
and recheck if the script if it could be made simply. the script is NOT used on a site more. like it's made[@LillePil] Welcome To ::: NickName::: Text