egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Adding features

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
bandidu
Voice


Joined: 20 Jul 2004
Posts: 5

PostPosted: Wed Jul 21, 2004 3:05 pm    Post subject: Adding features Reply with quote

This tcl was made for radios. It collects requests from users (listeners) in channel, send to announcer through private message.

Here is the code:

Code:
set canal "#Locutores"

set comando "!Pedido"
set comando1 "!Recado"
set djonline "n/a"
set djdesc "n/a"
set msg "n/a"
set pedido "0"
set recado "0"

if {![info exists timezone]} {
    set timezone "GMT+3"
}

#TOPICO

set topicos {
    "8,2[4Radio IRCBrasil0,2 ON8] 8Escute a Radio IRCBrasil em 0,7 http://play.ircbrasil.com.br 9,2 Locutor(a)0,2 $djonline 8,2* 9,2Programa0 $djdesc 8* SITE: 0www.ircbrasil.com.br * 11A Rádio Web Mais IrAdA do Brasil"
}
set ntopicos [llength $topicos]

set topico_num 0

#FIM

bind pub - !DJ pub_dj

proc pub_dj {nick uhost hand channel rest} {
    global canal botnick topicos ntopicos topico_num djonline djdesc
    set topico [lindex $topicos $topico_num]
    if {[incr topico_num] >= ${ntopicos}} { set topico_num 0 }
    if {[botisop $canal]==1} {
        if {[isop $nick $canal]} {
            set djonline [lindex $rest 0]
            set djdesc [lrange $rest 1 end]
            if {$djdesc != ""} {
                if {$djonline != ""} {
                    if {$djdesc != ""} {
                        if {$nick == $djonline} {
                            putserv "TOPIC $canal : [subst -nocommands $topico]"
                            putlog "$nick setou topico no canal."
                            putlog "O Dj foi mudado por $djonline para $nick"
                            putlog "O topico setado foi: [subst -nocommands $topico]"
                        }
                        if {$nick != $djonline} {
                            putserv "TOPIC $canal : [subst -nocommands $topico]"
                            putlog "$nick setou topico no canal."
                            putlog "O Dj foi mudado por $nick para $djonline"
                            putlog "O topico setado foi: [subst -nocommands $topico]"
                        }
                    }
                }
            }
        }
    }
    if {$djonline != ""} {
        if {$djdesc == ""}  {
            if {[botisop $canal]} {
                if {[isop $nick $canal]} {
                    set djdesc n/a
                    putserv "TOPIC $canal :[subst -nocommands $topico]"
                    putlog "$nick setou topico no canal sem o estilo."
                    putlog "O topico setado foi: [subst -nocommands $topico]"
                }
            }
        }
    }
    if {[isop $nick $canal]} {
        if {$djonline == ""} {
            if {$djdesc == ""}  {
                if {![botisop $canal]} {
                    puthelp "NOTICE $nick :5ERRO: $nick o comando deve ser assim: !DJ SEU NICK ESTILO."
                    puthelp "NOTICE $nick :5EX: !DJ $nick Rock."
                    puthelp "NOTICE $nick :5EX: Eu não sou um operador do $canal."
                    putlog "$nick usou !Dj mas nao sou op do $canal."
                    putlog "$nick sou !Dj sem informar Nick e estilo"
                    return 0
                }
            }
        }
    }
    if {[isop $nick $canal]} {
        if {$djonline != ""} {
            if {![botisop $canal]} {
                puthelp "NOTICE $nick :5EX: Eu não sou um operador do $canal."
                putlog "$nick tentou usar o comando !Dj mas não sou op do $canal."
            }
        }
    }
    if {$djonline == ""} {
        if {$djdesc == ""}  {
            if {[botisop $canal]} {
                if {[isop $nick $canal]} {
                    puthelp "NOTICE $nick :5ERRO: $nick o comando deve ser assim: !DJ SEU NICK ESTILO."
                    puthelp "NOTICE $nick :5EX: !DJ $nick Rock."
                    putlog "$nick tentou usar o comando !Dj sem informar o nick e o estilo."
                }
            }
        }
    }
    if {$djonline == ""} {
        if {$djdesc == ""}  {
            if {[botisop $canal]} {
                if {![isop $nick $canal]} {
                    puthelp "NOTICE $nick :5ERRO: $nick Este comando só pode ser utilizado por operadores do $canal."
                    putlog "$nick tentou usar o comando !Dj sem ser op do $canal."
                }
            }
        }
    }
    if {$djonline != ""} {
        if {$djdesc != ""}  {
            if {[botisop $canal]} {
                if {![isop $nick $canal]} {
                    puthelp "NOTICE $nick :5ERRO: $nick Este comando só pode ser utilizado por operadores do $canal."
                    putlog "$nick tentou usar o comando !Dj sem ser op do $canal."
                }
            }
        }
    }
    if {$djonline != ""} {
        if {$djdesc == ""}  {
            if {![isop $nick $canal]} {
                if {[botisop $canal]} {
                    puthelp "NOTICE $nick :5ERRO: $nick Este comando só pode ser utilizado por operadores do $canal"
                    putlog "$nick tentou usar o comando !Dj sem ser op do $canal."
                }
            }
        }
    }
    if {$djonline != ""} {
        if {$djdesc == ""}  {
            if {![isop $nick $canal]} {
                if {![botisop $canal]} {
                    puthelp "NOTICE $nick :5ERRO: $nick você não é um op do $canal."
                    puthelp "NOTICE $nick :Eu não sou um operador do $canal."
                    putlog "$nick tentou usar o comando !Dj sem ser op do $canal."
                }
            }
        }
    }
}

bind pub - !On pub_on
bind pub - !Off pub_off

proc pub_on {nick uhost hand channel rest} {
    global canal botnick djonline djdesc
    if {[botisop $canal]==1} {
        if {[isop $nick $canal]} {
            putserv "TOPIC $canal :8,2[4Radio IRCBrasil0,2 OFF8] 8Escute a Radio IRCBrasil em 0,7 http://play.ircbrasil.com.br 9,2 Locutor(a)0,2 N/A 8,2* 9,2Programa0 N/A 0,20,28* SITE: 0www.ircbrasil.com.br * 11A Rádio Web Mais IrAdA do Brasil"
            putlog "$nick setou topico no canal"
        }
    }
    if {![botisop $canal]==1} {
        if {[isop $nick $canal]} {
            puthelp "NOTICE $nick :5ERRO: $nick Eu não sou um op do $canal."
            putlog "$nick usou o comando mas nao sou op."
        }
    }
    if {[botisop $canal]==1} {
        if {![isop $nick $canal]} {
            puthelp "NOTICE $nick :5ERRO: Você não tem acesso para usar esse comando."
        }
    }
    if {![botisop $canal]==1} {
        if {![isop $nick $canal]} {
            puthelp "NOTICE $nick :5ERRO:Não sou um op do $canal. E você também não é um operador do $canal."
        }
    }
}

proc pub_off {nick uhost hand channel rest} {
    global canal botnick djonline djdesc
    if {[botisop $canal]==1} {
        if {[isop $nick $canal]} {
            putserv "TOPIC $canal :8,2[4Radio IRCBrasil0,2 OFF8] 8Escute a Radio IRCBrasil em 0,7 http://play.ircbrasil.com.br 9,2 Locutor(a)0,2 N/A 8,2* 9,2Programa0 N/A 0,20,28* SITE: 0www.ircbrasil.com.br * 11A Rádio Web Mais IrAdA do Brasil"
        }
    }
    if {![botisop $canal]==1} {
        if {[isop $nick $canal]} {
            puthelp "NOTICE $nick :5ERRO: $nick Eu não sou um op do $canal."
            putlog "$nick usou o comando, mas não sou Op do $canal."
        }
    }
    if {[botisop $canal]==1} {
        if {![isop $nick $canal]} {
            puthelp "NOTICE $nick :5ERRO: Você não tem acesso para usar esse comando."
            putlog "$nick tentou usar o comando !Dj sem ser op do $canal."
        }
    }
    if {![botisop $canal]==1} {
        if {![isop $nick $canal]} {
            puthelp "NOTICE $nick :5ERRO:Não sou um op do $canal."
            puthelp "NOTICE $nick :Você não é um operador do $canal."
            putlog "$nick tentou usar o comando !Dj sem ser op do $canal."
        }
    }
}

bind msg - "!Pedido" msg_pedido
bind msg - "!Recado" msg_recado
bind msg - "!DJ" msg_dj2
bind msg - "!info" msg_info
bind msg - "!Zerar" msg_zerar

proc msg_info {nick uhost hand rest} {
    global canal djonline djdesc pedido recado
    putserv "PRIVMSG $nick :O canal ativo é o $canal"
    putserv "PRIVMSG $nick :Dj online $djonline"
    putserv "PRIVMSG $nick :Estilo do Dj $djdesc"
    putserv "PRIVMSG $nick :Já foram enviado(s) $recado recado(s)"
    putserv "PRIVMSG $nick :Já foram enviado(s) $pedido pedido(s)"
}

proc msg_zerar {nick uhost hand rest} {
    global canal djonline djdesc pedido recado
    putserv "PRIVMSG $nick :Zerando . . ."
    set pedido "0"
    set recado "0"
    putserv "PRIVMSG $nick :Zerando recado(s)"
    putserv "PRIVMSG $nick :Zerando pedido(s)"

}

proc msg_pedido {nick uhost hand rest} {
    global botnick comando djonline djdesc msg pedido fpedido
    set msg [lrange $rest 0 end]
    set data "[strftime %d/%m/%Y]"
    set hora "[strftime %H:%M:%S]"
    if {$djonline != ""} {
        if {$nick != $djonline} {
            incr pedido 
            putserv "PRIVMSG $djonline :» $pedido « Pedido do{a} $nick ø O pedido é: $msg" 
            putlog "Enviando Pedido para $djonline de $nick com o seguinte pedido $msg"
            putserv "PRIVMSG $nick :Às $hora Seu Pedido Enviado com sucesso para $djonline."
        }
    }
}

proc msg_recado {nick uhost hand rest} {
    global botnick comando1 djonline djdesc msg recado frecado
    set msg [lrange $rest 0 end]
    set data "[strftime %d/%m/%Y]"
    set hora "[strftime %H:%M:%S]"
    if {$djonline != ""} {
        if {$nick != $djonline} {
            incr recado
            putserv "PRIVMSG $djonline :» $recado « ø Recado do{a} $nick ø O recado é: $msg" 
            putlog "Enviando Recado para $djonline de $nick com o seguinte recado $msg"
            putserv "PRIVMSG $nick :Às $hora Recado Enviado com sucesso para $djonline."
        }
    }
}

bind dcc m restart darrestart
proc darrestart {handle idx rest} {
    global botnick
    dccbroadcast "12#2#12# 2Dando rehash no12 $botnick2. Autorizado por12 $handle2."
    restart
}

# Inetrvalo maximo (EM MINUTOS) entre as mensagens:
set mF(msgintervalo) 8

# Messagens para serem enviadas ao canal(is):
set msgs(sexo) {
    "7,2[ 0,2Peça Músicas: 11/msg vitrola !pedido 11musica 10,2 Mande Recados: 11/msg vitrola !recado recado 7]"
}

# enviar mensagens para que canal?
set mF(canal) "#Locutores"

proc sendmsg {} {
    global botnick mF msgs www
    timer $mF(msgintervalo) sendmsg

    if {![info exists www]} { set www [expr [llength $msgs(sexo)]-1] }

    if {$www <= -1} {
        set www [expr [llength $msgs(sexo)]-1]
        set sendmsg1 "[lindex $msgs(sexo) $www]"
        set www [expr $www-1]
    } {
        set sendmsg1 "[lindex $msgs(sexo) $www]"
        set www [expr $www-1]
    }
    if {$sendmsg1 == ""} {
        set www [expr [llength $msgs(sexo)]-1]
        set www [expr $www-1]
        set sendmsg1 "[lindex $msgs(sexo) $www]"
    }
    putserv "PRIVMSG $mF(canal) :$sendmsg1"
}

if {![info exists loadsendmsg]} { sendmsg }
set loadsendmsg 1

set streamip "***.***.***.***"
set streamport "8000"
set streampass "****"
set sclistenertrigger ".pico"
set sclastsongstrigger ".musicapassada"
set scplayingtrigger ".musica"
set radiochans "#Locutores"


bind pub - $sclistenertrigger pub_listener
bind msg - $sclistenertrigger msg_listener

bind pub - $sclastsongstrigger pub_lastsongs
bind msg - $sclastsongstrigger msg_lastsongs

bind pub - $scplayingtrigger  pub_playing
bind msg - $scplayingtrigger  msg_playing

proc shrink { calc number string start bl} { return [expr [string first "$string" $bl $start] $calc $number] }

#COMEÇO !PICO

proc listener { target } {
global streamip streamport streampass
putlog "shoutcast: $target pediu o número de usuários ouvindo a IRCBrasil"
if {[catch {set sock [socket $streamip $streamport] } sockerror]} {
putlog "error: $sockerror"
return 0 } else {
puts $sock "GET /admin.cgi?pass=$streampass&mode=viewxml&page=0 HTTP/1.0"
puts $sock "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.9)"
puts $sock "Host: $streamip"
puts $sock "Connection: close"
puts $sock ""
flush $sock
while {[eof $sock] != 1} {
set bl [gets $sock]
if { [string first "standalone" $bl] != -1 } {
set repl [string range $bl [shrink + 19 "<REPORTEDLISTENERS>" 0 $bl] [shrink - 1 "</REPORTEDLISTENERS>" 0 $bl]]
set curhigh [string range $bl [shrink + 15 "<PEAKLISTENERS>" 0 $bl] [shrink - 1 "</PEAKLISTENERS>" 0 $bl]]
set maxl [string range $bl [shrink + 14 "<MAXLISTENERS>" 0 $bl] [shrink - 1 "</MAXLISTENERS>" 0 $bl]]
set avgtime [string range $bl [shrink + 13 "<AVERAGETIME>" 0 $bl] [shrink - 1 "</AVERAGETIME>" 0 $bl]]
}}
close $sock
putserv "notice $target :Há atualmente $repl pessoas ouvindo a rádio e o nosso pico de usuários é $curhigh ouvintes"
}}

proc msg_listener { nick uhost hand arg } { global radiochans; listener $nick }
proc pub_listener { nick uhost hand chan arg } { global radiochans; if {([lsearch -exact [string tolower $radiochans] [string tolower $chan]] != -1) || ($radiochans == "")} { listener $nick  }}

#FIM !PICO

#COMEÇO MUSICAS PASSADAS

proc sclastsongs { target } {
global streamip streamport streampass
putlog "shoutcast: $target pediu as músicas passadas"
if {[catch {set sock [socket $streamip $streamport] } sockerror]} {
putlog "error: $sockerror"
return 0 } else {
puts $sock "GET /admin.cgi?pass=$streampass&mode=viewxml&page=0 HTTP/1.0"
puts $sock "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.9)"
puts $sock "Host: $streamip"
puts $sock "Connection: close"
puts $sock ""
flush $sock
while {[eof $sock] != 1} {
set bl [gets $sock]
if { [string first "standalone" $bl] != -1 } {
set songs [string range $bl [string first "<TITLE>" $bl] [expr [string last "</TITLE>" $bl] + 7]]
regsub -all "&#x3C;" $songs "<" songs
regsub -all "&#x3E;" $songs ">" songs
regsub -all "&#x26;" $songs "+" songs
regsub -all "&#x22;" $songs "\"" songs
regsub -all "&#x27;" $songs "'" songs
regsub -all "&#xFF;" $songs "" songs
regsub -all "<TITLE>" $songs "(" songs
regsub -all "</TITLE>" $songs ")" songs
regsub -all "<SONG>" $songs "" songs
regsub -all "</SONG>" $songs " - " songs
regsub -all "<PLAYEDAT>" $songs "" songs
regsub -all "</PLAYEDAT>" $songs "" songs
regsub -all {\d} $songs "" songs
}}
putserv "notice $target :$songs"
}}


proc msg_lastsongs { nick uhost hand arg } { global radiochans; sclastsongs $nick }
proc pub_lastsongs { nick uhost hand chan arg } { global radiochans; if {([lsearch -exact [string tolower $radiochans] [string tolower $chan]] != -1) || ($radiochans == "")} { sclastsongs $nick }}

#FIM MUSICAS PASSADAS

#COMEÇO MUSICA ATUAL

proc playing {target} {
global streamip streamport streampass
putlog "shoutcast: $target asked for current song"
if {[catch {set sock [socket $streamip $streamport] } sockerror]} {
putlog "error: $sockerror"
return 0 } else {
puts $sock "GET /admin.cgi?pass=$streampass&mode=viewxml&page=0 HTTP/1.0"
puts $sock "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.9)"
puts $sock "Host: $streamip"
puts $sock "Connection: close"
puts $sock ""
flush $sock
while {[eof $sock] != 1} {
set bl [gets $sock]
if { [string first "standalone" $bl] != -1 } {
set streamstatus [string range $bl [shrink + 14 "<STREAMSTATUS>" 0 $bl] [shrink - 1 "</STREAMSTATUS>" 0 $bl]]
set songtitle [string range $bl [shrink + 11 "<SONGTITLE" 0 $bl] [shrink - 1 "</SONGTITLE>" 0 $bl]]
set songurl [string range $bl [shrink + 9 "<SONGURL>" 0 $bl] [shrink - 1 "</SONGURL>" 0 $bl]]
if {$songurl != ""} { set songurl " ($songurl)"}
regsub -all "&#x3C;" $songtitle "<" songtitle
regsub -all "&#x3E;" $songtitle ">" songtitle
regsub -all "&#x26;" $songtitle "+" songtitle 
regsub -all "&#x22;" $songtitle "\"" songtitle
regsub -all "&#x27;" $songtitle "'" songtitle
regsub -all "&#xFF;" $songtitle "" songtitle
if {$streamstatus == 1} {
putserv "notice $target :IRCBrasil Bombando com $songtitle$songurl"
} else {
putserv "notice $target :A Rádio parece estar offline"
}}}
close $sock
}}

proc msg_playing { nick uhost hand arg } { global radiochans; playing $nick}
proc pub_playing { nick uhost hand chan arg } { global radiochans; if {([lsearch -exact [string tolower $radiochans] [string tolower $chan]] != -1) || ($radiochans == "")} { playing $nick  }}

#FIM MUSICA ATUAL

set nicks "IRC"


bind join - * proc_entranado
bind nick - * proc_nick

proc proc_entranado {nick uhost handle channel args} {
    global canal nicks
    if {[string tolower $channel] == [string tolower $canal]} {
        foreach var $nicks {
            if {[string match "*[string tolower $nick]*" "[string tolower $var]"]} {
                if {[botisop $canal]} {
                    pushmode $canal +v $nick
                }
            }
        }
    }
}

proc proc_nick {nick uhost handle channel newnick} {
    global nicks canal
    if {[string tolower $channel] == [string tolower $canal]} {
        foreach var $nicks {
            if {[string match "*[string tolower $newnick]*" "[string tolower $var]"]} {
                if {[botisop $canal]} {
                    pushmode $canal +v $newnick
                }
            }
        }
    }
}


I'd like to add some features, but I don't know how to do that. The features are:

Protection

Block repeated requests
Block sent requests in few seconds

Changes

Send the requests to announcher through chat (Preventing lag and disconnection by flood)
Add a command to turn the advertisements off.

If no one cannot help me, suggest me another person.

PS: Don't mind about the text written in portuguese, because I'm brazilian. Sorry my bad english.. hehe Wink
Back to top
View user's profile Send private message
Alchera
Revered One


Joined: 11 Aug 2003
Posts: 3344
Location: Ballarat Victoria, Australia

PostPosted: Wed Jul 21, 2004 3:47 pm    Post subject: Reply with quote

I'd suggest contacting the author of the script with your suggestions so that they may add them in a future (updated) release. Smile
_________________
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
Back to top
View user's profile Send private message Visit poster's website
bandidu
Voice


Joined: 20 Jul 2004
Posts: 5

PostPosted: Thu Jul 22, 2004 2:10 am    Post subject: Reply with quote

That was the first thing, I've done. If he could help me, I wouldn't be here Cool
Back to top
View user's profile Send private message
bandidu
Voice


Joined: 20 Jul 2004
Posts: 5

PostPosted: Sat Jul 24, 2004 12:59 am    Post subject: Reply with quote

Someone please help me Sad
Back to top
View user's profile Send private message
alisetan
Voice


Joined: 21 May 2006
Posts: 36

PostPosted: Tue Aug 01, 2006 9:19 am    Post subject: Reply with quote

bandidu wrote:
Someone please help me Sad



put the english version on that tcl plss
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber