Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!
- # I'm an eggdrop compat source
- set dbuser {puck} ;# this protects it from special characters by making it a string literal
- set dbpass {password}
- set reporterrors 1
- package require mysqltcl
- bind pub D "!requests" pub_request
- proc pub_request {nick host handle channel text} {
- global dbuser dbpass ;# expose vars to this procedure, you can upvar by $::varname as well instead of using global
- if {[catch {set db [::mysql::connect -host localhost -user $dbuser -password $dbpass -db radio]} errmsg]} {
- putlog "Error:$errmsg"
- if {$::reporterrors == 1} { puthelp "PRIVMSG $channel :Error:$errmsg" }
- }
- #you could wrap this in a catch statement as well.
- set result [::mysql::sel $db "SELECT id,song,name,message FROM request WHERE bot_site_read = 'no' LIMIT 1"];
- if {$result < 1} {
- puthelp "PRIVMSG #webradio :\x02$nick\x02, Checked database. No new requests/messages."
- } else {
- ::mysql::map $db {id song name message} {
- puthelp "PRIVMSG $channel :\x02\[Request\x02\] Song: $song Message: $message By: $name"
- ::mysql::sel $db "UPDATE request SET bot_site_read = 'yes' WHERE id = '$id'"
- }
- }
- ::mysql::close $db
- }
- putlog "Loaded noname script"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement