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.
Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
-
traxwriter
- Voice
- Posts: 5
- Joined: Wed Mar 21, 2007 4:27 pm
Post
by traxwriter »
Hi,
I'm looking for a script that will voice a user if their name is in a mysql db
if they are not in the db print "Please use your site name to gain your IRC bonus $username"
Thanks in advance
I have a irc idle script I wondder if I could integrate into that:
Code: Select all
load /usr/lib/mysqltcl-2.30/libmysqltcl2.30.so
package require mysqltcl
set db_handle [mysqlconnect -host localhost -socket /var/run/mysqld/mysqld.sock -user user -password pass -db database]
bind join - "#channel *" join_main
bind part - "#channel *" part_main
bind sign - "#channel *" sign_main
bind nick - "#channel *" nick_main
proc sign_main {nick uhost hand channel reason} {
global db_handle botnick
if {$nick==$botnick} {return 0}
set sql "UPDATE users SET onirc = 'no' WHERE username = '$nick'"
putloglev d * "ircstats: executing $sql"
set result [mysqlexec $db_handle $sql]
if {$result != 1} {
putlog "SQL - Error"
} else {
set id [mysqlinsertid $db_handle]
puthelp "PRIVMSG $channel :5 User Offline: \002$nick\002 - IRC bonus disabled"
}
}
proc join_main {nick uhost hand channel} {
global db_handle botnick
if {$nick==$botnick} {return 0}
set sql "UPDATE users SET onirc = 'yes' WHERE username = '$nick'"
putloglev d * "ircstats: executing $sql"
set result [mysqlexec $db_handle $sql]
if {$result != 1} {
putlog "SQL - error"
} else {
set id [mysqlinsertid $db_handle]
puthelp "PRIVMSG $channel :9 User Online: \002$nick\002 - IRC bonus enabled."
}
}
proc part_main {nick uhost hand channel msg} {
global db_handle botnick
if {$nick==$botnick} {return 0}
set sql "UPDATE users SET onirc = 'no' WHERE username = '$nick'"
putloglev d * "ircstats: executing $sql"
set result [mysqlexec $db_handle $sql]
if {$result != 1} {
putlog "SQL - Error"
} else {
set id [mysqlinsertid $db_handle]
puthelp "PRIVMSG $channel :5 User Offline: \002$nick\002 - IRC bonus disabled"
}
}
proc nick_main {nick uhost handle channel newnick} {
global db_handle botnick
# if {$nick==$botnick} {return 0}
set sql "UPDATE users SET onirc = 'no' WHERE username = '$nick'"
putloglev d * "ircstats: executing $sql"
set result [mysqlexec $db_handle $sql]
if {$result != 1} {
set sql "UPDATE users SET onirc = 'yes' WHERE username = '$newnick'"
putloglev d * "ircstats: executing $sql"
set result [mysqlexec $db_handle $sql]
putlog "SQL - Error"
if {$result != 1} {
putlog "SQL - Error"
} else {
set id [mysqlinsertid $db_handle]
puthelp "PRIVMSG $channel :9 User Online \002$newnick\002 - IRC bonus enabled"
}
} else {
set id [mysqlinsertid $db_handle]
puthelp "PRIVMSG $channel :5 User Offline \002$nick\002 - IRC bonus disabled"
}
}
-
DayCuts
- Voice
- Posts: 37
- Joined: Tue Jun 15, 2004 8:43 am
Post
by DayCuts »
All you really need to do is use pushmode after the user online messages.
Altered script (not tested but should be fine).
Code: Select all
load /usr/lib/mysqltcl-2.30/libmysqltcl2.30.so
package require mysqltcl
set db_handle [mysqlconnect -host localhost -socket /var/run/mysqld/mysqld.sock -user user -password pass -db database]
bind join - "#channel *" join_main
bind part - "#channel *" part_main
bind sign - "#channel *" sign_main
bind nick - "#channel *" nick_main
proc sign_main {nick uhost hand channel reason} {
global db_handle botnick
if {$nick==$botnick} {return 0}
set sql "UPDATE users SET onirc = 'no' WHERE username = '$nick'"
putloglev d * "ircstats: executing $sql"
set result [mysqlexec $db_handle $sql]
if {$result != 1} {
putlog "SQL - Error"
} else {
set id [mysqlinsertid $db_handle]
puthelp "PRIVMSG $channel :5 User Offline: \002$nick\002 - IRC bonus disabled"
}
}
proc join_main {nick uhost hand channel} {
global db_handle botnick
if {$nick==$botnick} {return 0}
set sql "UPDATE users SET onirc = 'yes' WHERE username = '$nick'"
putloglev d * "ircstats: executing $sql"
set result [mysqlexec $db_handle $sql]
if {$result != 1} {
putlog "SQL - error"
} else {
set id [mysqlinsertid $db_handle]
puthelp "PRIVMSG $channel :9 User Online: \002$nick\002 - IRC bonus enabled."
pushmode $channel +v $nick
}
}
proc part_main {nick uhost hand channel msg} {
global db_handle botnick
if {$nick==$botnick} {return 0}
set sql "UPDATE users SET onirc = 'no' WHERE username = '$nick'"
putloglev d * "ircstats: executing $sql"
set result [mysqlexec $db_handle $sql]
if {$result != 1} {
putlog "SQL - Error"
} else {
set id [mysqlinsertid $db_handle]
puthelp "PRIVMSG $channel :5 User Offline: \002$nick\002 - IRC bonus disabled"
}
}
proc nick_main {nick uhost handle channel newnick} {
global db_handle botnick
# if {$nick==$botnick} {return 0}
set sql "UPDATE users SET onirc = 'no' WHERE username = '$nick'"
putloglev d * "ircstats: executing $sql"
set result [mysqlexec $db_handle $sql]
if {$result != 1} {
set sql "UPDATE users SET onirc = 'yes' WHERE username = '$newnick'"
putloglev d * "ircstats: executing $sql"
set result [mysqlexec $db_handle $sql]
putlog "SQL - Error"
if {$result != 1} {
putlog "SQL - Error"
} else {
set id [mysqlinsertid $db_handle]
puthelp "PRIVMSG $channel :9 User Online \002$newnick\002 - IRC bonus enabled"
pushmode $channel +v $newnick
}
} else {
set id [mysqlinsertid $db_handle]
puthelp "PRIVMSG $channel :5 User Offline \002$nick\002 - IRC bonus disabled"
pushmode -v $newnick
}
}
Stand alone script.
Code: Select all
load /usr/lib/mysqltcl-2.30/libmysqltcl2.30.so
package require mysqltcl
set vdb_handle [mysqlconnect -host localhost -socket /var/run/mysqld/mysqld.sock -user user -password pass -db database]
bind join - "#channel *" vjoin_main
bind nick - "#channel *" vnick_main
proc vjoin_main {nick uhost hand channel} {
global vdb_handle botnick
if {$nick==$botnick} {return 0}
set nickv [mysqlescape $nick]
set sql "SELECT username FROM users WHERE username = '$nickv' LIMIT 1"
putloglev d * "ircstats: executing $sql"
set result [mysqlsel $db_handle $sql -flatlist]
if {[llength [split $result]] == 1} {
pushmode $chan +v $nick
}
}
proc vnick_main {nick uhost handle channel newnick} {
global vdb_handle botnick
if {$newnick==$botnick} {return 0}
set sql "SELECT username FROM users WHERE username = '[mysqlescape $newnick]' LIMIT 1"
putloglev d * "ircstats: executing $sql"
set result [mysqlsel $db_handle $sql -flatlist]
if {[llength [split $result1]] == 1} {
pushmode $chan +v $newnick
} else {
pushmode $chan -v $newnick
}
}
-
traxwriter
- Voice
- Posts: 5
- Joined: Wed Mar 21, 2007 4:27 pm
Post
by traxwriter »
Thats great thanks DayCuts
-
traxwriter
- Voice
- Posts: 5
- Joined: Wed Mar 21, 2007 4:27 pm
Post
by traxwriter »
OK that didn't work, but you prompted me to sort it myself:
Replace:
pushmode $chan +v $nick
With:
putserv "MODE $channel +v $nick"
And Replace:
pushmode $chan -v $newnick
With:
putserv "MODE $channel -v $newnick"
Thanks