Ok so what i'm trying to do is let users log into the bot so they can use commands. When they login it gives them a specific flag (+G) and then all commands are based off G. when they part/quit it takes it away.
Now i have the login all working and it adds/takes the flag, but users can't seem to use the commands. Here is some of the code
bind msg G .commands proc_commands
bind msg - .login proc_login
bind msg G .logout proc_logout
proc proc_login { nick uhost hand text } {
global host user pass db
set con [::mysql::connect -host $host -user $user -password $pass]
set res [::mysql::use $con $db]
set md5pass [md5 $text]
set query [::mysql::query $con "SELECT * FROM users WHERE username='$nick' AND password='$md5pass'"]
if {[set row [::mysql::fetch $query]] == ""} {
putserv "PRIVMSG $nick :Incorrect Login"
} else {
putserv "PRIVMSG $nick :Logged in"
adduser $nick
chattr $nick +G
}
::mysql::endquery $query
::mysql::close $con
}
proc proc_commands { nick uhost hand text } {
putserv "PRIVMSG $nick :All commands can be accessed in this private chat, or by typing /msg K1-Bot <command>"
putserv "PRIVMSG $nick :-"
putserv "PRIVMSG $nick :Commands:"
putserv "PRIVMSG $nick :.logout (Logs you out of the bot)"
}
Now, when i login it seems to work, but doesn't work when another user does it. Any reason why?
adduser <handle> [hostmask]
Description: creates a new user entry with the handle and hostmask given
(with no password and the default flags)
Returns: 1 if successful; 0 if the handle already exists
Module: core
Basically, you're creating a new user-account (based on nickname), but neglect to add any hostmasks to it. Hence your eggdrop cannot identify the user as the user-account. Add a proper hostmask.
Also, I would strongly suggest that you add some mechanism to check that the added handle-name does not already exists (or test the result of the adduser command).