Advertisement
Guest User

Untitled

a guest
Jul 7th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.77 KB | None | 0 0
  1. proc pub:commands {nick uhost handle channel arg} {
  2. putserv "PRIVMSG $channel :\002\00314,1\[\0039«\002\0030 !request !works !channels !addwork !remove !edit \002\0039,1»\00314]"
  3. }
  4. bind pub - !commands pub:commands
  5.  
  6. proc pub:request {nick uhost handle channel arg} {
  7. putserv "PRIVMSG $channel :\002\00314,1\[\0039«\002\0030 Regras para fazer um Request \002\0039,1»\00314]"
  8. }
  9. bind pub - !request pub:request
  10.  
  11. proc pub:works {nick uhost handle channel arg} {
  12. if {![info exists eplay_db] || ([info exists eplay_db] && [mysqlstate $eplay_db] == "7" || [info exists eplay_db] && [mysqlstate $eplay_db] == "UNCONNECTED")} {
  13. set eplay_db [::mysql::connect -host "localhost" -user "eplay" -password "..." -db "eplay"]
  14. }
  15. #if {![info exists db(sqlhand)] || ([info exists db(sqlhand)] && [mysqlstate $db(sqlhand)] == "7" || [info exists db(sqlhand)] && [mysqlstate $db(sqlhand)] == "UNCONNECTED")} {
  16. #set db(sqlhand) [mysqlconnect -host $eplay(dbhost) -user $eplay(dbuser) -password $eplay(dbpass) -db $eplay(dbname)]
  17. #}
  18. global eplay_db
  19. if {[::mysql::sel $eplay_db {SELECT * FROM works}] > 0} {
  20. ::mysql::map $eplay_db {auth status link} {
  21. putserv "PRIVMSG $channel :\002\00314,1\[\0039«\002\0030 By $auth - (\00304$status\0030) - $link \002\0039,1»\00314]"
  22. }
  23. } else {
  24. putserv "PRIVMSG $channel :\002\00314,1\[\0039«\002\0030 Não há works disponíveis neste momento. \002\0039,1»\00314]"
  25. }
  26. }
  27. bind pub - !works pub:works
  28.  
  29. proc pub:channels {nick uhost handle channel arg} {
  30. putserv "PRIVMSG $channel :\002\00314,1\[\0039«\002\0030 Canal Eplay Youtube \002\0039,1»\00314]"
  31. }
  32. bind pub - !channels pub:channels
  33.  
  34. proc pub:addwork {nick uhost handle channel arg} {
  35.  
  36. global eplay_db
  37. set arg [split [join $arg]]
  38. if {[isop $nick $channel]} {
  39. set auth [lindex $arg 0]
  40. set status [lindex $arg 1]
  41. set link [lindex $arg 2]
  42. if {$auth != {} && $status != {} && $link != {}} {
  43. set auth [::mysql::escape $eplay_db $auth]
  44. set status [::mysql::escape $eplay_db $status]
  45. set link [::mysql::escape $eplay_db $link]
  46. set r1 [::mysql::sel $eplay_db "SELECT 1 FROM works WHERE link = '$link'"]
  47. if {$r1 == 0} {
  48. set r2 [::mysql::exec $eplay_db "INSERT INTO works VALUES ('$auth','$status','$link')"]
  49. if {$r2 == 1} {
  50. putserv "PRIVMSG $channel :\002\00314,1\[\0039«\002\0030 Work adicionado com sucesso \002\0039,1»\00314]"
  51. } else {
  52. putserv "PRIVMSG $channel :\002\00314,1\[\0039«\002\0030 Ocorreu um erro ao adicionar o work. Por favor, tenta outra vez. \002\0039,1»\00314]"
  53. }
  54. } else {
  55. putserv "PRIVMSG $channel :$nick: Esse work já existe"
  56. }
  57. } else {
  58. putserv "PRIVMSG $channel :\002\00314,1\[\0039«\002\0030 Sintaxe: !addwork <auth> <status> <link> \002\0039,1»\00314]"
  59. }
  60. }
  61. }
  62. bind pub - !addwork pub:addwork
  63.  
  64. proc pub:remove {nick uhost handle channel arg} {
  65.  
  66. global eplay_db
  67. set arg [split [join $arg]]
  68. if {[isop $nick $channel]} {
  69. set link [lindex $arg 0]
  70. if {$link != {}} {
  71. set link [::mysql::escape $eplay_db $link]
  72. set r1 [::mysql::sel $eplay_db "SELECT 1 FROM works WHERE link = '$link'"]
  73. if {$r1 > 0} {
  74. set r2 [::mysql::exec $eplay_db "DELETE FROM works WHERE link = '$link'"]
  75. if {$r2 == 1} {
  76. putserv "PRIVMSG $channel :\002\00314,1\[\0039«\002\0030 Work removido com sucesso \002\0039,1»\00314]"
  77. } else {
  78. putserv "PRIVMSG $channel :\002\00314,1\[\0039«\002\0030 Ocorreu um erro ao remover o work. Por favor, tenta outra vez. \002\0039,1»\00314]"
  79. }
  80. } else {
  81. putserv "PRIVMSG $channel :$nick: Esse work não existe"
  82. }
  83. } else {
  84. putserv "PRIVMSG $channel :\002\00314,1\[\0039«\002\0030 Sintaxe: !remove <link> \002\0039,1»\00314]"
  85. }
  86. }
  87. }
  88. bind pub - !remove pub:remove
  89.  
  90. proc pub:edit {nick uhost handle channel arg} {
  91.  
  92. global eplay_db
  93. set arg [split [join $arg]]
  94. if {[isop $nick $channel]} {
  95. set link [lindex $arg 0]
  96. if {$link != {}} {
  97. set link [::mysql::escape $eplay_db $link]
  98. set r1 [::mysql::sel $eplay_db "SELECT 1 FROM works WHERE link = '$link'"]
  99. if {$r1 > 0} {
  100. set r2 [::mysql::exec $eplay_db "UPDATE works SET status = '$status' WHERE link = '$link'"]
  101. if {$r2 == 1} {
  102. putserv "PRIVMSG $channel :\002\00314,1\[\0039«\002\0030 Work editado com sucesso \002\0039,1»\00314]"
  103. } else {
  104. putserv "PRIVMSG $channel :\002\00314,1\[\0039«\002\0030 Ocorreu um erro ao editar o work. Por favor, tenta outra vez. \002\0039,1»\00314]"
  105. }
  106. } else {
  107. putserv "PRIVMSG $channel :$link: Esse work não existe"
  108. }
  109. } else {
  110. putserv "PRIVMSG $channel :\002\00314,1\[\0039«\002\0030 Sintaxe: !edit <status> <link> \002\0039,1»\00314]"
  111. }
  112. }
  113. }
  114. bind pub - !edit pub:edit
  115.  
  116.  
  117. package require mysqltcl
  118.  
  119. set eplay_db [::mysql::connect -host "localhost" -user "eplay" -password "..." -db "eplay"]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement