Advertisement
Guest User

Untitled

a guest
Jun 30th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. #!
  2. # I'm an eggdrop compat source
  3.  
  4. set dbuser {puck} ;# this protects it from special characters by making it a string literal
  5. set dbpass {password}
  6. set reporterrors 1
  7. package require mysqltcl
  8.  
  9. bind pub D "!requests" pub_request
  10.  
  11. proc pub_request {nick host handle channel text} {
  12. global dbuser dbpass ;# expose vars to this procedure, you can upvar by $::varname as well instead of using global
  13. if {[catch {set db [::mysql::connect -host localhost -user $dbuser -password $dbpass -db radio]} errmsg]} {
  14. putlog "Error:$errmsg"
  15. if {$::reporterrors == 1} { puthelp "PRIVMSG $channel :Error:$errmsg" }
  16. }
  17. #you could wrap this in a catch statement as well.
  18. set result [::mysql::sel $db "SELECT id,song,name,message FROM request WHERE bot_site_read = 'no' LIMIT 1"];
  19. if {$result < 1} {
  20. puthelp "PRIVMSG #webradio :\x02$nick\x02, Checked database. No new requests/messages."
  21. } else {
  22. ::mysql::map $db {id song name message} {
  23. puthelp "PRIVMSG $channel :\x02\[Request\x02\] Song: $song Message: $message By: $name"
  24. ::mysql::sel $db "UPDATE request SET bot_site_read = 'yes' WHERE id = '$id'"
  25. }
  26. }
  27. ::mysql::close $db
  28. }
  29.  
  30. putlog "Loaded noname script"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement