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 !edit \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} {
- if {![info exists eplay_db] || ([info exists eplay_db] && [mysqlstate $eplay_db] == "7" || [info exists eplay_db] && [mysqlstate $eplay_db] == "UNCONNECTED")} {
- set eplay_db [::mysql::connect -host "localhost" -user "eplay" -password "..." -db "eplay"]
- }
- #if {![info exists db(sqlhand)] || ([info exists db(sqlhand)] && [mysqlstate $db(sqlhand)] == "7" || [info exists db(sqlhand)] && [mysqlstate $db(sqlhand)] == "UNCONNECTED")} {
- #set db(sqlhand) [mysqlconnect -host $eplay(dbhost) -user $eplay(dbuser) -password $eplay(dbpass) -db $eplay(dbname)]
- #}
- 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 - (\00304$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 link = '$link'"]
- 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 {$link != {}} {
- set link [::mysql::escape $eplay_db $link]
- set r1 [::mysql::sel $eplay_db "SELECT 1 FROM works WHERE link = '$link'"]
- if {$r1 > 0} {
- set r2 [::mysql::exec $eplay_db "DELETE FROM works WHERE link = '$link'"]
- if {$r2 == 1} {
- putserv "PRIVMSG $channel :\002\00314,1\[\0039«\002\0030 Work removido com sucesso \002\0039,1»\00314]"
- } else {
- 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]"
- }
- } else {
- putserv "PRIVMSG $channel :$nick: Esse work não existe"
- }
- } else {
- putserv "PRIVMSG $channel :\002\00314,1\[\0039«\002\0030 Sintaxe: !remove <link> \002\0039,1»\00314]"
- }
- }
- }
- bind pub - !remove pub:remove
- proc pub:edit {nick uhost handle channel arg} {
- global eplay_db
- set arg [split [join $arg]]
- if {[isop $nick $channel]} {
- set link [lindex $arg 0]
- if {$link != {}} {
- set link [::mysql::escape $eplay_db $link]
- set r1 [::mysql::sel $eplay_db "SELECT 1 FROM works WHERE link = '$link'"]
- if {$r1 > 0} {
- set r2 [::mysql::exec $eplay_db "UPDATE works SET status = '$status' WHERE link = '$link'"]
- if {$r2 == 1} {
- putserv "PRIVMSG $channel :\002\00314,1\[\0039«\002\0030 Work editado com sucesso \002\0039,1»\00314]"
- } else {
- 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]"
- }
- } else {
- putserv "PRIVMSG $channel :$link: Esse work não existe"
- }
- } else {
- putserv "PRIVMSG $channel :\002\00314,1\[\0039«\002\0030 Sintaxe: !edit <status> <link> \002\0039,1»\00314]"
- }
- }
- }
- bind pub - !edit pub:edit
- 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