egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Need help to get the join script working

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
Fire-Fox
Master


Joined: 23 Sep 2006
Posts: 270
Location: /dev/null

PostPosted: Fri Jun 19, 2009 11:48 am    Post subject: Need help to get the join script working Reply with quote

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:
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
Back to top
View user's profile Send private message MSN Messenger
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Fri Jun 19, 2009 8:48 pm    Post subject: Reply with quote

Code:
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. Wink
_________________
speechles' eggdrop tcl archive
Back to top
View user's profile Send private message
Fire-Fox
Master


Joined: 23 Sep 2006
Posts: 270
Location: /dev/null

PostPosted: Sat Jun 20, 2009 5:49 am    Post subject: Reply with quote

thanks so fare Smile

Anyone know the error :

Code:
##################
### 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
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber