Advertisement
Guest User

Untitled

a guest
Jun 30th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. #!
  2. # I'm an eggdrop compat source
  3.  
  4. set dbuser {username} ;# 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 - "!request" pub_request
  10.  
  11. proc pub_request {name 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 song,name,message FROM request WHERE check='' LIMIT 1"];
  19. if {$result == 1} {
  20. puthelp "PRIVMSG $channel :\x02$nick\x02, Checked database. No new requests/messages."
  21. } else {
  22. ::mysql::map $db {song name message} {
  23. puthelp "PRIVMSG $channel :\x02\[Request\x02\] Song: $song Message: $message By: $name"
  24. }
  25. }
  26. ::mysql::close $db
  27. }
  28.  
  29. putlog "Loaded noname script"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement