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 

Help please

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
blake
Master


Joined: 23 Feb 2009
Posts: 201

PostPosted: Wed Feb 22, 2012 1:51 pm    Post subject: Help please Reply with quote

Hey I found the following script here on the forums and want to try see if it works on my server but i get the following error on the partyline

Also would like to beable to get it to work for any channels i set in the script not just one channel

Quote:
Tcl error [joins]: bad option "--": must be -nocase or -length


This is the script
Code:

package require mysqltcl

#-> Change the information below to connect to your MySQL database
set mysqlserver localhost;
set mysqluser ***;
set mysqlpwd ***;
set mysqldb ***;

#-> Change the chan below for the chan you wish to monitor
set userChan "#test"

bind join - * joins
proc joins {nick host hand chan} {
   global userChan
   if {[string equal -nocase -- $chan $userChan]} {
      set db_handle [mysqlconnect -h $::mysqlserver -u $::mysqluser -password $::mysqlpwd];
      mysqluse $db_handle $::mysqldb
      set sql "SELECT id FROM users WHERE username='[mysqlescape $nick]'"
      set result [mysqlsel $db_handle $sql -list]
   }
   set result [mysqlsel $db_handle $sql -list]
   if {$result > 0 } {
      putserv "NOTICE $userChan $nick :welcome"
   } else {
      putserv "kick $userChan $nick :To join this channel you first need to register at http://cwukchat.com/modules/profile/register.php"
      mysqlclose $db_handle;
   }
}

Many Thanks
_________________
Blake
UKEasyHosting UKStormWatch
Back to top
View user's profile Send private message Visit poster's website
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Wed Feb 22, 2012 2:22 pm    Post subject: Reply with quote

Code:

if {[string equal -nocase -- $chan $userChan]} {

Have you tried removing -- in this line?
_________________
Once the game is over, the king and the pawn go back in the same box.
Back to top
View user's profile Send private message
Johannes13
Halfop


Joined: 10 Oct 2010
Posts: 46

PostPosted: Wed Feb 22, 2012 3:46 pm    Post subject: Reply with quote

Please note that this script is unsafe.
I can choose one of the new users on the site and join the chan with such a nick, and change the nick after that to my real nick like Johannes13

An other thing is that the mysql handle is not closed when the nick is valid.
PROTIP: warp all the stuff after mysqlconnect with a catch, so if there is an error, it will still close the mysql handle

Ok, here a version (it still only checks the nicks, but probably you want to make sure that the nick is registered with nickserv or smillar (by setting a channel mode that let only registered users join etc..)

Code:

package require mysqltcl

#-> Change the information below to connect to your MySQL database
set mysqlserver localhost;
set mysqluser ***;
set mysqlpwd ***;
set mysqldb ***;

#-> Change the chan below for the chan you wish to monitor
setudef flag checknick

bind join - * joins
proc joins {nick host hand chan} {
   if {[channel get $chan checknick]} {
      set db_handle [mysqlconnect -h $::mysqlserver -u $::mysqluser -password $::mysqlpwd];
      set code [catch {
         mysqluse $db_handle $::mysqldb
         set sql "SELECT id FROM users WHERE username='[mysqlescape $nick]'"
         set result [mysqlsel $db_handle $sql -list]
      } res opt]
      mysqlclose $db_handle
      if {$code != 0} {
         return -opt $opt $res
      }
      if {$result > 0 } {
         putserv "NOTICE $nick :welcome"
      } else {
         putserv "kick $chan $nick :To join this channel you first need to register at http://cwukchat.com/modules/profile/register.php"
      }
   }

}


And it uses now a flag, so you can activate that script for more than 1 channel. (use .chanset #channel +checknick)

PS.: I think, I used again some Tcl 8.5 features.. so if you have an older version of Tcl installed, it does not work.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help 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