Mise en forme de code: pensez à utiliser les balises [ tcl ] et [ /tcl ] (sans les espaces bien sûr) autour de vos codes tcl afin d'avoir un meilleur rendu et une coloration syntaxique. x


récupérer un php
#1
bonjour
je suis a la recherche d'un tcl qui permet de lire un php pour que mon eggdrop le transmet dans la salle avec une commande style !musique
merci pour l aide
Cordialement T4tou
  Reply
#2
Ton eggdrop ne pourra pas lire (et interpréter) un php, il peut juste se connecter au site (donc à la page php) avec le code suivant:

tcl
package require http
package require tls
bind pub - !musique getpage
proc getpage {nick uhost handle chan text} {
   ::http::register https 443 [list ::tls::socket -autoservername true]
   set tok [::http::geturl https://ton.adresse.de.site/musique.php]
   putserv "PRIVMSG $chan :[::http::data $tok]"
   ::http::cleanup $tok
   ::http::unregister https
}

zeolia: tchat gratuit, sans inscription ni publicité
Merci de ne pas demander d'aide en MP
Away
  Reply
#3
(15/08/2021, 16:13)CrazyCat Wrote: Ton eggdrop ne pourra pas lire (et interpréter) un php, il peut juste se connecter au site (donc à la page php) avec le code suivant:

tcl
package require http
package require tls
bind pub - !musique getpage
proc getpage {nick uhost handle chan text} {
  ::http::register https 443 [list ::tls::socket -autoservername true]
  set tok [::http::geturl https://ton.adresse.de.site/musique.php]
  putserv "PRIVMSG $chan :[::http::data $tok]"
  ::http::cleanup $tok
  ::http::unregister https
}

merci pour ton aide
il me dit comme erreur
Tcl error in script for 'timer27':
Unsupported URL type "https"
pouriez vous m aider
merci
  Reply
#4
Je pense que tu as un autre script qui fait des requêtes http (et même https), basées sur un timer probablement, et que ce script fait le register https une seule fois à l'initialisation, ce qui est une énorme erreur.
Ca peut être rss-synd ou n'importe lequel autre que tu as chargé sur ton eggdrop et qui a besoin d'accéder à un site web. A toi de retrouver lequel, personne d'autre ne pourra le faire à ta place
zeolia: tchat gratuit, sans inscription ni publicité
Merci de ne pas demander d'aide en MP
Away
  Reply
#5
(16/08/2021, 00:33)CrazyCat Wrote: Je pense que tu as un autre script qui fait des requêtes http (et même https), basées sur un timer probablement, et que ce script fait le register https une seule fois à l'initialisation, ce qui est une énorme erreur.
Ca peut être rss-synd ou n'importe lequel autre que tu as chargé sur ton eggdrop et qui a besoin d'accéder à un site web. A toi de retrouver lequel, personne d'autre ne pourra le faire à ta place

merci pour la reponse je pense que l erreur viens d ici


tcl
package require http
package require tls 
http::register https 443 [list ::tls::socket -require 0 -request 1] 
 
 
 
set icevar(site) "https://tchatcam.net/"
set icevar(pagejson) "json.php"
set icevar(artiste) ""
set icevar(titre) ""
set icevar(atitre) ""
set icevar(audit) ""
set icevar(accueil) 1
set icevar(#tchatcam) { "\00304Taper !cmd pour mes commandes" }
 
 
bind pubm - * ice:public
bind time - "15 19 * * *" ice:ausecours
bind join -|- * ice:join
 
utimer 5 {ice:actu}
 
 
proc ice:join {nick uhost hand channel} {
	global icevar botnick
	if {$icevar(accueil)&&[info exists icevar($channel)]&&($nick != $botnick)} {
	   puthelp "NOTICE $nick :[lindex $icevar($channel) [rand [llength $icevar($channel)]]]"
	   return 1
	}
}
 
 
proc ice:public { nick userhost handle chan text } {
	global icevar
	regsub -all -- {\003[0-9]{0,2}(,[0-9]{0,2})?|\017|\037|\002|\026|\006|\007} $text "" text
	set c [string range $text 0 0]
	set v 0
	scan $c %c v
    if { $v == 32 } { set text [string range $text 1 end] }
 
	if { $text == "!titre" } {
		putquick "PRIVMSG #tchatcam :\0036Le Vous écoutez en ce moment \0033 $icevar(titre)"
	}
	if { $text == "!audit" } {
		putquick "PRIVMSG #tchatcam :\0036Il y a \0033 $icevar(audit) \0036 auditeurs sur tchatcam radio."
	}	
	if { $text == "!radio" } {
		putquick "PRIVMSG #tchatcam :\00302Pour écouter la radio"
		putquick "PRIVMSG #tchatcam :\00304VLC --> \0031https://tchatcam.net/tchatcam.pls"
		putquick "PRIVMSG #tchatcam :\00305Winamp --> \0031https://tchatcam.net/tchatcam.m3u"
		putquick "PRIVMSG #tchatcam :\00312stream --> \0031https://tchatcam.net:8443/tchatcam"
		putquick "PRIVMSG #tchatcam :\00302Bonne ecoute a tous :)"
	}
	if { $text == "!cmd" } {
		putquick "PRIVMSG #tchatcam :\00302voici les commandes"
		putquick "PRIVMSG #tchatcam :\00305!titre \00304--> \00312Titre qui passe a la radio"
		putquick "PRIVMSG #tchatcam :\00305!radio \00304--> \00312Liens pour ecouter la radio"
		putquick "PRIVMSG #tchatcam :\00305!audit \00304--> \00312Nombres auditeur sur la radio"
		putquick "PRIVMSG #tchatcam :\00302Bonne ecoute"
	}
 
}	
 
# actualise les titres en salle
proc ice:actu {} {
	global icevar
 
	set body [ice:req $icevar(pagejson)]
 
	set info [split $body "@"]
	if { [lindex $body 0] != "Unknown " } { 
		set icevar(titre) [string trim [lindex $info 1]]
		set icevar(audit) [string trim [lindex $info 0]]
	}
	if { $icevar(titre) != $icevar(atitre) } {
		putquick "privmsg #tchatcam :\0036En ce moment sur\00310 Radio tchatcam \0033 $icevar(titre)"
		set icevar(atitre) $icevar(titre)
	}
	utimer 5 {ice:actu}
}
 
 
#recupere les infos venant de json.php (icecast)
proc ice:req { page } {
	global icevar
 
	set query $icevar(site)$page
	set agent "Mozilla"
	set token [http::config -useragent $agent]
	set token [http::geturl $query -timeout 8000]
	puts stderr ""
	upvar #0 $token state
	set tbody $state(body)
	set token [http::cleanup $token]
	return $tbody
}
 
 
proc ice:ausecours {minute hour day month year} {
	restart
}

Edit utiliser les balises [ tcl ] et [ /tcl ] pour mettre du code
  Reply
#6
Effectivement, il faut modifier le code ainsi:

tcl
package require http
package require tls 
 
set icevar(site) "https://tchatcam.net/"
set icevar(pagejson) "json.php"
set icevar(artiste) ""
set icevar(titre) ""
set icevar(atitre) ""
set icevar(audit) ""
set icevar(accueil) 1
set icevar(#tchatcam) { "\00304Taper !cmd pour mes commandes" }
 
bind pubm - * ice:public
bind time - "15 19 * * *" ice:ausecours
bind join -|- * ice:join
utimer 5 {ice:actu}
 
proc ice:join {nick uhost hand channel} {
	global icevar botnick
	if {$icevar(accueil)&&[info exists icevar($channel)]&&($nick != $botnick)} {
	   puthelp "NOTICE $nick :[lindex $icevar($channel) [rand [llength $icevar($channel)]]]"
	   return 1
	}
}
 
proc ice:public { nick userhost handle chan text } {
	global icevar
	regsub -all -- {\003[0-9]{0,2}(,[0-9]{0,2})?|\017|\037|\002|\026|\006|\007} $text "" text
	set c [string range $text 0 0]
	set v 0
	scan $c %c v
    if { $v == 32 } { set text [string range $text 1 end] }
	if { $text == "!titre" } {
		putquick "PRIVMSG #tchatcam :\0036Le Vous écoutez en ce moment \0033 $icevar(titre)"
	}
	if { $text == "!audit" } {
		putquick "PRIVMSG #tchatcam :\0036Il y a \0033 $icevar(audit) \0036 auditeurs sur tchatcam radio."
	}	
	if { $text == "!radio" } {
		putquick "PRIVMSG #tchatcam :\00302Pour écouter la radio"
		putquick "PRIVMSG #tchatcam :\00304VLC --> \0031https://tchatcam.net/tchatcam.pls"
		putquick "PRIVMSG #tchatcam :\00305Winamp --> \0031https://tchatcam.net/tchatcam.m3u"
		putquick "PRIVMSG #tchatcam :\00312stream --> \0031https://tchatcam.net:8443/tchatcam"
		putquick "PRIVMSG #tchatcam :\00302Bonne ecoute a tous :)"
	}
	if { $text == "!cmd" } {
		putquick "PRIVMSG #tchatcam :\00302voici les commandes"
		putquick "PRIVMSG #tchatcam :\00305!titre \00304--> \00312Titre qui passe a la radio"
		putquick "PRIVMSG #tchatcam :\00305!radio \00304--> \00312Liens pour ecouter la radio"
		putquick "PRIVMSG #tchatcam :\00305!audit \00304--> \00312Nombres auditeur sur la radio"
		putquick "PRIVMSG #tchatcam :\00302Bonne ecoute"
	}
}
 
# actualise les titres en salle
proc ice:actu {} {
	global icevar
	set body [ice:req $icevar(pagejson)]
	set info [split $body "@"]
	if { [lindex $body 0] != "Unknown " } { 
		set icevar(titre) [string trim [lindex $info 1]]
		set icevar(audit) [string trim [lindex $info 0]]
	}
	if { $icevar(titre) != $icevar(atitre) } {
		putquick "privmsg #tchatcam :\0036En ce moment sur\00310 Radio tchatcam \0033 $icevar(titre)"
		set icevar(atitre) $icevar(titre)
	}
	utimer 5 {ice:actu}
}
 
#recupere les infos venant de json.php (icecast)
proc ice:req { page } {
	global icevar
	::http::register https 443 [list ::tls::socket -require 0 -request 1] 
	set query $icevar(site)$page
	set agent "Mozilla"
	set token [::http::config -useragent $agent]
	set token [::http::geturl $query -timeout 8000]
	puts stderr ""
	upvar #0 $token state
	set tbody $state(body)
	set token [::http::cleanup $token]
	::http::unregister https
	return $tbody
}
 
proc ice:ausecours {minute hour day month year} {
	restart
}

zeolia: tchat gratuit, sans inscription ni publicité
Merci de ne pas demander d'aide en MP
Away
  Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [Résolu] récupérer texte dans page html BrYcOu 5 5,703 22/09/2015, 06:46
Last Post: BrYcOu
  [Demande] Récupérer le contenu de la timeline BetaSeries.com KiBa 1 3,570 29/10/2013, 15:12
Last Post: aliasangelius
  [Demande] Récupérer certaines infos dans fichier .user Hitsu 5 5,180 30/07/2013, 17:13
Last Post: CrazyCat
  [Recherche] TCL pour récupérer des infos sur un site Maxwell 14 8,811 04/05/2013, 10:50
Last Post: Maxwell
  recuperer les infos d'une page web loulou7593 0 3,708 23/12/2011, 00:20
Last Post: loulou7593
  récupérer le nom de la procédure parent [résolu] MenzAgitat 4 4,834 28/05/2009, 22:39
Last Post: BdS

Forum Jump:


Users browsing this thread: 1 Guest(s)