Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- proc pub:commands {nick uhost handle channel arg} {
- putserv "PRIVMSG $channel :\002\00314,1\[\0039«\002\0030 !request !works !channels !addwork !remove \002\0039,1»\00314]"
- }
- bind pub - !commands pub:commands
- proc pub:request {nick uhost handle channel arg} {
- putserv "PRIVMSG $channel :\002\00314,1\[\0039«\002\0030 Regras para fazer um Request \002\0039,1»\00314]"
- }
- bind pub - !request pub:request
- proc pub:works {nick uhost handle channel arg} {
- global eplay_db
- if {[::mysql::sel $eplay_db {SELECT * FROM works}] > 0} {
- ::mysql::map $eplay_db {auth status link} {
- putserv "PRIVMSG $channel :\002\00314,1\[\0039«\002\0030 By $auth - (\0034$status\0030) - $link \002\0039,1»\00314]"
- }
- } else {
- putserv "PRIVMSG $channel :\002\00314,1\[\0039«\002\0030 Não há works disponíveis neste momento. \002\0039,1»\00314]"
- }
- }
- bind pub - !works pub:works
- proc pub:channels {nick uhost handle channel arg} {
- putserv "PRIVMSG $channel :\002\00314,1\[\0039«\002\0030 Canal Eplay Youtube \002\0039,1»\00314]"
- }
- bind pub - !channels pub:channels
- proc pub:addwork {nick uhost handle channel arg} {
- global eplay_db
- set arg [split [join $arg]]
- if {[isop $nick $channel]} {
- set auth [lindex $arg 0]
- set status [lindex $arg 1]
- set link [lindex $arg 2]
- if {$auth != {} && $status != {} && $link != {}} {
- set auth [::mysql::escape $eplay_db $auth]
- set status [::mysql::escape $eplay_db $status]
- set link [::mysql::escape $eplay_db $link]
- set r1 [::mysql::sel $eplay_db "SELECT 1 FROM works WHERE auth = '$auth'"]
- if {$r1 == 0} {
- set r2 [::mysql::exec $eplay_db "INSERT INTO works VALUES ('$auth','$status','$link')"]
- if {$r2 == 1} {
- putserv "PRIVMSG $channel :\002\00314,1\[\0039«\002\0030 Work adicionado com sucesso \002\0039,1»\00314]"
- } else {
- 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]"
- }
- } else {
- putserv "PRIVMSG $channel :$nick: Esse work já existe"
- }
- } else {
- putserv "PRIVMSG $channel :\002\00314,1\[\0039«\002\0030 Sintaxe: !addwork <auth> <status> <link> \002\0039,1»\00314]"
- }
- }
- }
- bind pub - !addwork pub:addwork
- proc pub:remove {nick uhost handle channel arg} {
- global eplay_db
- set arg [split [join $arg]]
- if {[isop $nick $channel]} {
- set link [lindex $arg 0]
- if {$auth != {} && $status != {} && $link != {}} {
- set link [::mysql::escape $eplay_db $link]
- set r1 [::mysql::sel $eplay_db "SELECT 1 FROM works WHERE auth = '$auth'"]
- if {$r1 == 0} {
- set r2 [::mysql::exec $eplay_db "REMOVE INTO works VALUES ('$auth','$status','$link')"]
- if {$r2 == 1} {
- putserv "PRIVMSG $channel :\002\00314,1\[\0039«\002\0030 Work adicionado com sucesso \002\0039,1»\00314]"
- } else {
- 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]"
- }
- } else {
- putserv "PRIVMSG $channel :$nick: Esse work já existe"
- }
- } else {
- putserv "PRIVMSG $channel :\002\00314,1\[\0039«\002\0030 Sintaxe: !addwork <auth> <status> <link> \002\0039,1»\00314]"
- }
- }
- }
- bind pub - !remove pub:remove
- package require mysqltcl
- set eplay_db [::mysql::connect -host "localhost" -user "eplay" -password "..." -db "eplay"]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement