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.05 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. proc request {name host handle channel text} {
  10. global dbuser dbpass ;# expose vars to this procedure, you can upvar by $::varname as well instead of using global
  11. if {[catch {set db [::mysql::connect -host localhost -user $dbuser -password $dbpass -db radio]} errmsg]} {
  12. putlog "Error:$errmsg"
  13. if {$::reporterrors == 1} { puthelp "PRIVMSG $channel :Error:$errmsg" }
  14. }
  15. #you could wrap this in a catch statement as well.
  16. set result [::mysql::sel $db "SELECT song,name,message FROM request WHERE check='' LIMIT 1"];
  17. if {$result == 1} {
  18. puthelp "PRIVMSG $channel :\x02$nick\x02, Checked database. No new requests/messages."
  19. } else {
  20. ::mysql::map $db {song name message} {
  21. puthelp "PRIVMSG $channel :\x02\[Request\x02\] Song: $song Message: $message By: $name"
  22. }
  23. }
  24. ::mysql::close $db
  25. }
  26.  
  27. putlog "Loaded noname script"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement