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 

invite/password script using mysql db search

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


Joined: 15 Jan 2009
Posts: 5

PostPosted: Fri Jan 16, 2009 4:08 am    Post subject: invite/password script using mysql db search Reply with quote

Hi,

I was hoping somebody would be able to create a script for me that listens for a privmsg invite with a password (ie. /msg bot invite username password or /msg bot username password invite). It would then compare the username and password to a mysqldb to see if they match. If they both match then an invite to the channel is given to the requesting nick, if either are wrong a simple wrong user/pass msg is sent to the nick requesting the invite.

eg

/msg bot username password invite

bot checks mysqldb for matching username/password

if found it issues the invite

if no match found no invite

error msg sent.

Many thanks in advance.
Back to top
View user's profile Send private message
tomekk
Master


Joined: 28 Nov 2008
Posts: 255
Location: Oswiecim / Poland

PostPosted: Tue Jan 20, 2009 8:32 am    Post subject: Reply with quote

try:
Code:
# Author: tomekk
# e-mail:  tomekk/@/oswiecim/./eu/./org
# home page: http://tomekk.oswiecim.eu.org/
#
# Version 0.1
#
# This file is Copyrighted under the GNU Public License.
# http://www.gnu.org/copyleft/gpl.html

# command: /msg botnick invite <username> <password>

# invite channel
set invite_chan "#channel"

# mysql db user
set msql_user "user"

# mysql db pass
set msql_pass "pass"

# mysql server host
set msql_host "localhost"

# mysql usernames/passwords database
set msql_dbase "eggdrop_users"

# mysql usernames/passwords table
set msql_table "users"

##################################################################
bind msgm - "*" invite_privs

package require mysqltcl

proc invite_privs { nick uhost hand arg } {
   global msql_user msql_pass msql_host msql_dbase msql_table invite_chan

   set all_prv_args [split $arg]
   set priv_command [lindex $all_prv_args 0]
   set priv_username [lindex $all_prv_args 1]
   set priv_password [lindex $all_prv_args 2]

   set login_ok 0

   if {($priv_command == "invite") && ($priv_username != "") && ($priv_password != "")} {
      set m_hand [::mysql::connect -host $msql_host -user $msql_user -password $msql_pass]
      ::mysql::use $m_hand $msql_dbase

      set users_passwords [::mysql::sel $m_hand "SELECT username, password FROM $msql_table" -list]

      ::mysql::close $m_hand

      foreach u_and_p $users_passwords {
         if {$u_and_p != ""} {
            set u_and_p_split [split $u_and_p]
            set user_name [lindex $u_and_p_split 0]
            set user_pass [lindex $u_and_p_split 1]

            if {$priv_username == $user_name} {
               if {$priv_password == $user_pass} {
                  set login_ok 1
               }
            }
         }
      }

      if {$login_ok == 0} {
         putquick "PRIVMSG $nick :wrong username or wrong password, sorry"
      } {
         putserv "INVITE $nick $invite_chan"
      }
   }
}

putlog "mysql_invite.tcl ver 0.1 by tomekk loaded"


table for it:
Code:
create table users (
        id int(4) auto_increment,
        username varchar(12),
        password varchar(12),
        primary key(id)
);


testing:
Quote:
13:29:29 <tomekk> invite test qwert
13:29:29 <botty> wrong username or wrong password, sorry


Quote:
13:30:29 <tomekk> invite test qwerty
13:30:32 [10] -!- botty invites you to #channel


users/passes are stored one by one, all in plain text:
user pass
user2 pass2
etc etc

Quote:
mysql> select * from users;
+----+----------+----------+
| id | username | password |
+----+----------+----------+
| 1 | tomekk | 123456 |
| 2 | test | qwerty |
+----+----------+----------+



Quote:
mysql> describe users;
+----------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+----------------+
| id | int(4) | NO | PRI | NULL | auto_increment |
| username | varchar(12) | YES | | NULL | |
| password | varchar(12) | YES | | NULL | |
+----------+-------------+------+-----+---------+----------------+


:>


Last edited by tomekk on Tue Jan 20, 2009 8:37 am; edited 5 times in total
Back to top
View user's profile Send private message Visit poster's website
incith
Master


Joined: 23 Apr 2005
Posts: 275
Location: Canada

PostPosted: Tue Jan 20, 2009 8:43 am    Post subject: Reply with quote

Impressive tomekk. Smile
_________________
; Answer a few unanswered posts!
Back to top
View user's profile Send private message
OzMan
Voice


Joined: 15 Jan 2009
Posts: 5

PostPosted: Thu Jan 22, 2009 5:17 am    Post subject: LEGEND!! Reply with quote

Thank you so much tomekk,

that script works GREAT!!!!!


You are a legend!!!!
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 -> 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