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.

Need help to get the join script working

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
User avatar
Fire-Fox
Master
Posts: 299
Joined: Sat Sep 23, 2006 9:01 pm
Location: /dev/null

Need help to get the join script working

Post by Fire-Fox »

Hey all...


i have this join msg script.

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]

Code: Select all

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

    }
  }
GreatZ
Fire-Fox | Denmark

Scripts: Relay | Store Text | TvMaze
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

Code: Select all

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. ;)
User avatar
Fire-Fox
Master
Posts: 299
Joined: Sat Sep 23, 2006 9:01 pm
Location: /dev/null

Post by Fire-Fox »

thanks so fare :)

Anyone know the error :

Code: Select all

##################
### 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]
GreatZ
Fire-Fox | Denmark

Scripts: Relay | Store Text | TvMaze
Post Reply