#
##############################################################
# TCL RADIO POUR RNG CODER PAR [Flo] #
##############################################################
#
package require mysqltcl
#
########################
# CONFIGURATION DU TCL #
########################
#
# récupère le la variable titre
set ::basetitre ""
# récupère le titre
set ::titre ""
# Salon ou serra poser le robot radio
set ::salradio "#RnG"
set ::salradio2 "#accueil"
set ::salon "#accueil #rng"
# Nom de la radio
set ::anim "R-n-G"
# Url pour afficher toute les 10 mins une pub sur le général.
set ::url "http://www.r-n-g.fr"
set ::url2 "http://www.facebook.com/pages/R-n-G-La-Puissance-de-la-Musique/141307675927662"
set ::cmds "!radio"
set SQL_HOST "localhost"
set SQL_LOGIN "rng"
set SQL_PASS "pass"
set SQL_BASE "rng"
set SQL_SOCK "/var/run/mysqld/mysqld.sock"
#
##################################
# FIN DE LA CONFIGURATION DU TCL #
# A PARTIR D ICI NE PLUS TOUCHER #
# SI VOUS CONNAISSER PAS LE TCL #
##################################
#
#
#############
# LES BINDS #
#############
#
bind pub - !dedicace stream:pub:dedi
bind msg - dedicace stream:msg:dedi
bind pub - !titre stream:pub:titre
bind msg - titre stream:msg:titre
bind pub - !radio stream:pub:radio
bind msg - radio stream:msg:radio
bind pub - !ecoute stream:pub:ecoute
bind msg - ecoute stream:msg:ecoute
bind pub - !facebook stream:pub:face
bind msg - facebook stream:msg:face
bind time - "00 03 * * *" stream:time:animation
bind time - "00 * * * *" stream:time:pub
bind join RM * stream:animteur
bind join RF * stream:animatrice
#
#################
# FIN DES BINDS #
#################
#
proc mysql:connect {} {
set ::mysqlink [mysqlconnect -host $::SQL_HOST -user $::SQL_LOGIN -password $::SQL_PASS -sock $::SQL_SOCK]
mysqluse $::mysqlink $::SQL_BASE
}
proc mysql:deconnect {} {
mysqlclose $::mysqlink; unset -nocomplain ::mysqlink
}
proc mysql:add_dedi {user dedi} {
mysql:connect
mysqlsel $::mysqlink "INSERT INTO site_dedi VALUES('', '$user', '$dedi', 'irc')"
mysql:deconnect
}
#
################
# DEBUG ACCENT #
################
#
proc debuf {code_text} {
regsub -all "‘" $code_text "\[" code_text
regsub -all "“" $code_text "\]" code_text
regsub -all "<" $code_text "<" code_text
regsub -all ">" $code_text ">" code_text
regsub -all """ $code_text "\"" code_text
regsub -all "'" $code_text "'" code_text
regsub -all "ÿ" $code_text "" code_text
regsub -all "´" $code_text "´" code_text
regsub -all "–" $code_text "-" code_text
regsub -all "ü" $code_text "ü" code_text
regsub -all "Ö" $code_text "Ö" code_text
regsub -all "Ä" $code_text "Ä" code_text
regsub -all "Ü" $code_text "í" code_text
regsub -all "à" $code_text "à" code_text
regsub -all "á" $code_text "á" code_text
regsub -all "â" $code_text "â" code_text
regsub -all "ã" $code_text "ã" code_text
regsub -all "ä" $code_text "ä" code_text
regsub -all "ç" $code_text "ç" code_text
regsub -all "è" $code_text "è" code_text
regsub -all "é" $code_text "é" code_text
regsub -all "ê" $code_text "ê" code_text
regsub -all "ë" $code_text "ë" code_text
regsub -all "ì" $code_text "ì" code_text
regsub -all "í" $code_text "í" code_text
regsub -all "î" $code_text "î" code_text
regsub -all "ï" $code_text "ï" code_text
regsub -all "ö" $code_text "ö" code_text
regsub -all "ü" $code_text "ü" code_text
regsub -all "¨" $code_text "¨" code_text
regsub -all "ù" $code_text "ù" code_text
regsub -all "{" $code_text "" code_text
regsub -all "#x26;" $code_text "" code_text
regsub -all "}" $code_text "" code_text
return $code_text
}
#
######################
# AFFICHAGE DU TITRE #
######################
#
proc stream:pub:titre {nick uhost handle channel data} {
set ::page "http://www.r-n-g.fr/website_sources/shoutcast.inc.php"
set ::oups [http::geturl $::page ]
set ::titre [http::data $::oups ]
set ::titre [split $::titre]
set ::titre2 [ debuf $::titre ]
if { $::titre2 != $::basetitre } {
foreach a [channels] {
if {[string equal -nocase $channel $a]} {
set ::basetitre $::titre2
putquick "NOTICE $nick :\0033..::: \0034$::anim \0033:::..\0033 \0032Vous Propose d'écouter: \0033..::: \0034 $::titre2 \0033:::..\0032"
} else {
return $::titre2
}
utimer 15 [list untel 1]
}
}
}
proc stream:msg:titre {nick uhost channel handle data} {
set ::page "http://www.r-n-g.fr/website_sources/shoutcast.inc.php"
set ::oups [http::geturl $::page ]
set ::titre [http::data $::oups ]
set ::titre [split $::titre]
set ::titre2 [ debuf $::titre ]
if { $::titre2 != $::basetitre } {
foreach a $::salon {
if {[string equal -nocase $channel $a]} {
set ::basetitre $::titre2
putquick "NOTICE $nick :\0033..::: \0034$::anim \0033:::..\0033 \0032Vous Propose d'écouter: \0033..::: \0034 $::titre2 \0033:::..\0032"
} else {
return $::titre2
}
utimer 15 [list untel 1]
}
}
}
#
##############################
# TIMER POUR REBOOT LE ROBOT #
##############################
#
proc stream:time:animation {min hour day month year } {
putquick "PRIVMSG $::salradio : \037\00302 Relancement automatique du bot :\037"
restart
}
#
#############################################
# TIMER POUR AFFICHER LA PUB SUR LE GENERAL #
#############################################
#
proc stream:time:pub {min hour day month year } {
putquick "PRIVMSG $::salradio :\0033..::: Pour écouter notre webradio , rendez-vous à l'adresse suivante: $::url :::..\003"
putquick "PRIVMSG $::salradio2 :\0033..::: Pour écouter notre webradio , rendez-vous en tapent la commande suivante: $::cmds :::..\0033"
}
#
##################
# COMMANDE RADIO #
##################
#
proc stream:pub:radio { nick uhost handle chan arg } {
set arg [split $arg]
set xchan [lindex $arg 1]
foreach a $::salon {
if {[string equal -nocase $chan $a]} {
putserv "NOTICE $nick :---\002 COMMANDES USER \002---"
putserv "NOTICE $nick :"
putserv "NOTICE $nick :!ecoute !titre !dedicace !facebook"
putserv "NOTICE $nick :"
putserv "NOTICE $nick :Vous pouvez aussi faire les commandes en privé:"
putserv "NOTICE $nick :"
putserv "NOTICE $nick :Exemple: /msg $::botnick ecoute"
putserv "NOTICE $nick : /msg $::botnick titre"
putserv "NOTICE $nick : /msg $::botnick dedicace"
putserv "NOTICE $nick : /msg $::botnick facebook"
putserv "NOTICE $nick :"
putserv "NOTICE $nick :Bonne écoute sur R-n-G."
putserv "NOTICE $nick :"
putserv "NOTICE $nick :---\002 FIN COMMANDES \002---"
}
}
}
proc stream:pub:ecoute { nick host hand chan arg } {
foreach a $::salon {
if {[string equal -nocase $chan $a]} {
putserv "NOTICE $nick : \0033..::: Pour écouter notre webradio , rendez-vous à l'adresse suivante : $::url :::..\003"
}
}
}
proc stream:msg:ecoute { nick host hand chan arg } {
foreach a $::salon {
if {[string equal -nocase $chan $a]} {
putserv "NOTICE $nick : \0033..::: Pour écouter notre webradio , rendez-vous à l'adresse suivante : $::url :::..\003"
}
}
}
proc stream:pub:face { nick host hand chan arg } {
foreach a $::salon {
if {[string equal -nocase $chan $a]} {
putserv "NOTICE $nick : \0033..::: Pour venir nous rejoindre est soutenir la webradio Rendez-vous sur Facebook : $::url2 :::..\003"
}
}
}
proc stream:msg:face { nick host hand chan arg } {
foreach a $::salon {
if {[string equal -nocase $chan $a]} {
putserv "NOTICE $nick : \0033..::: Pour venir nous rejoindre est soutenir la webradio Rendez-vous sur Facebook : $::url2 :::..\003"
}
}
}
proc stream:msg:dedi {nick uhost handle data} {
set temp [open "djnick" r]
set djnick [gets $temp]
if {$data == ""} {putquick "NOTICE $nick :Erreur, un argument est manquant !"}
putquick "NOTICE $nick :\0033Votre dédicasse a bien été transmise !"
putquick "NOTICE $nick :\0037Elle sera peut-être lue d'ici quelques instants à l'antenne de R-n-G ;)"
putquick "NOTICE $nick :\0034Attention, si vous envoyez trops de dédicasses en un court laps de temps , vous serez ignoré par nos services."
putquick "PRIVMSG $djnick :\002Dédicace\002 de \002$nick\002: $data "
utimer 1 [list mysql:add_dedi $nick $data]
}
proc stream:pub:dedi {nick uhost handle channel data} {
set temp [open "djnick" r]
set djnick [gets $temp]
if {$data == ""} {putquick "NOTICE $nick :Erreur, un argument est manquant !"}
putquick "NOTICE $nick :\0033Votre dédicasse a bien été transmise !"
putquick "NOTICE $nick :\0037Elle sera peut-être lue d'ici quelques instants à l'antenne de R-n-G ;)"
putquick "NOTICE $nick :\0034Attention, si vous envoyez trops de dédicasses en un court laps de temps , vous serez ignoré par nos services."
putquick "PRIVMSG $djnick :\002Dédicace\002 de \002$nick\002: $data "
utimer 1 [list mysql:add_dedi $nick $data]
}
#
############
# INFOLINE #
############
#
proc stream:animteur {nick host hand chan} {
putquick "PRIVMSG $chan :\2\0031\[\0032$hand\0031\] \002\0035Animateur R-n-G "
pushmode $::salradio +h $nick
}
proc stream:animatrice {nick host hand chan} {
putquick "PRIVMSG $chan :\2\0031\[\0032$hand\0031\] \002\0035Animatrice R-n-G "
pushmode $::salradio +h $nick
}
putlog "\0036STREAM.TCL CREER PAR [Flo] POUR RNG"