This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.
For more information, see this announcement post . Click the X in the top right-corner of this box to dismiss this message.
Help for those learning Tcl or writing their own scripts.
flink
Halfop
Posts: 83 Joined: Sun Feb 21, 2021 9:27 am
Location: Canarias
Post
by flink » Tue Mar 15, 2022 9:16 am
CrazyCat passed me this script to see who can help me I adapted a dj room to put the mute/unmute commands as it would be so that it would only pay attention in that room not in radichan too and the direct command does not work for me can someone help me thank you very much
Code: Select all
namespace eval radio {
variable streamurl "https://zenoplay.zenomedia.com/api/zenofm/nowplaying/ffvwrxpufzzuv"
variable radiochan "#yourchan"
variable radiodj "#yourchandj"
package require http
package require tls
variable cursong ""
bind pub - !direct ::radio::pub:getstream
bind pub -|n !mute ::radio::mute
bind pub -|n !unmute ::radio::unmute
proc mute {nick uhost handle chan text} {
unbind cron - "* * * * *" ::radio::getstream
putserv "privmsg $::radio::radiodj :4parado los anuncios.."
}
proc unmute {nick uhost handle chan text} {
bind cron - "* * * * *" ::radio::getstream
putserv "privmsg $::radio::radiodj :4Puesto en Automatico los anuncios.."
}
proc pub:getstream {nick uhost handle chan text} {
if {[::string tolower $chan] ne $::radio::radiochan } {
return
}
::radio::getstream 0 0 0 0 0
}
proc getstream {mi ho da mo wd} {
::http::register https 443 ::tls::socket
set tok [::http::geturl $::radio::streamurl]
set source [::radio::json2dict [::http::data $tok]]
::http::cleanup $tok
::http::unregister https
set title [dict get $source title]
set artist [dict get $source artist]
if {$::radio::cursong ne $title} {
set ::radio::cursong $title
set artist [encoding convertfrom utf-8 [string map {"&" "&"} $artist]]
set title [encoding convertfrom utf-8 [string map {"&" "&"} $title]]
putserv "PRIVMSG $::radio::radiochan :Ahora Suena : 3$title de 2$artist "
}
}
proc json2dict {JSONtext} {
string range [string trim [string trimleft [string map {\t {} \n {} \r {} , { } : { } \[ \{ \] \}} $JSONtext] {\uFEFF}]] 1 end-1
}
}
Mi ingles: no es el mejor, Manda el traductor...
CrazyCat
Revered One
Posts: 1306 Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:
Post
by CrazyCat » Tue Mar 15, 2022 10:10 am
Not sure to understand your trouble. Which command must be used in which channel with which effect ?
SpiKe^^
Owner
Posts: 831 Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:
Post
by SpiKe^^ » Tue Mar 15, 2022 10:21 am
This should make the !mute and !unmute commands to function only in the radiodj "#yourchandj" channel.
Code: Select all
namespace eval radio {
variable streamurl "https://zenoplay.zenomedia.com/api/zenofm/nowplaying/ffvwrxpufzzuv"
variable radiochan "#yourchan"
variable radiodj "#yourchandj"
package require http
package require tls
variable cursong ""
bind pub - !direct ::radio::pub:getstream
bind pub -|n !mute ::radio::mute
bind pub -|n !unmute ::radio::unmute
proc mute {nick uhost handle chan text} {
if {![string equal -nocase $chan $::radio::radiodj]} { return 0 }
unbind cron - "* * * * *" ::radio::getstream
putserv "privmsg $::radio::radiodj :4parado los anuncios.."
}
proc unmute {nick uhost handle chan text} {
if {![string equal -nocase $chan $::radio::radiodj]} { return 0 }
bind cron - "* * * * *" ::radio::getstream
putserv "privmsg $::radio::radiodj :4Puesto en Automatico los anuncios.."
}
proc pub:getstream {nick uhost handle chan text} {
if {![string equal -nocase $chan $::radio::radiochan]} { return 0 }
::radio::getstream 0 0 0 0 0
}
proc getstream {mi ho da mo wd} {
::http::register https 443 ::tls::socket
set tok [::http::geturl $::radio::streamurl]
set source [::radio::json2dict [::http::data $tok]]
::http::cleanup $tok
::http::unregister https
set title [dict get $source title]
set artist [dict get $source artist]
if {$::radio::cursong ne $title} {
set ::radio::cursong $title
set artist [encoding convertfrom utf-8 [string map {"&" "&"} $artist]]
set title [encoding convertfrom utf-8 [string map {"&" "&"} $title]]
putserv "PRIVMSG $::radio::radiochan :Ahora Suena : 3$title de 2$artist "
}
}
proc json2dict {JSONtext} {
string range [string trim [string trimleft [string map {\t {} \n {} \r {} , { } : { } \[ \{ \] \}} $JSONtext] {\uFEFF}]] 1 end-1
}
}
Last edited by
SpiKe^^ on Tue Mar 15, 2022 1:03 pm, edited 1 time in total.
flink
Halfop
Posts: 83 Joined: Sun Feb 21, 2021 9:27 am
Location: Canarias
Post
by flink » Tue Mar 15, 2022 10:47 am
thanks for reply SpiKe^^
I tried it and it doesn't work for me pass the commands !unmute
! mute in radiochan and the messages came out in radiodj as if it was connected & disconnected
Mi ingles: no es el mejor, Manda el traductor...
SpiKe^^
Owner
Posts: 831 Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:
Post
by SpiKe^^ » Tue Mar 15, 2022 10:51 am
Now you have both of us very confused.
Please try to explain what you are after here...
flink
Halfop
Posts: 83 Joined: Sun Feb 21, 2021 9:27 am
Location: Canarias
Post
by flink » Tue Mar 15, 2022 12:56 pm
hello again, i wanted the !unmute & !mute commands to work only in the radiodj room with the solution you gave me they only work in the radiochan room and the !direct command doesn't work it doesn't do anything thanks very much
Mi ingles: no es el mejor, Manda el traductor...
SpiKe^^
Owner
Posts: 831 Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:
Post
by SpiKe^^ » Tue Mar 15, 2022 1:06 pm
Slightly changed the above fix I posted.
You need to .restart the bot to remove all earlier binds!
flink
Halfop
Posts: 83 Joined: Sun Feb 21, 2021 9:27 am
Location: Canarias
Post
by flink » Tue Mar 15, 2022 1:27 pm
well it's true my mistake, I rebooted and the radiodj !unmute & !mute room commands worked but the other !direct command doesn't work in either room thanks again
Mi ingles: no es el mejor, Manda el traductor...
SpiKe^^
Owner
Posts: 831 Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:
Post
by SpiKe^^ » Tue Mar 15, 2022 1:47 pm
I was just fixing the room specific public !unmute & !mute command deal.
(Post subject: how to centralize the commands only in a room)
If the script is unable to get data from the webpage that's a whole different deal.
Maybe CrazyCat can figure out why the script no longer works?
flink
Halfop
Posts: 83 Joined: Sun Feb 21, 2021 9:27 am
Location: Canarias
Post
by flink » Tue Mar 15, 2022 2:06 pm
the data is obtained from the web page because when you use !unmute and it enters in automatic mode when changing the song if it jumps in the room the song that is playing at that moment.
But when you use the !direct command it doesn't play anything.
I think I understand that it is for that very reason to say the song that is playing at that time or am I confused?
again thank you very much for helping and being there
Mi ingles: no es el mejor, Manda el traductor...
SpiKe^^
Owner
Posts: 831 Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:
Post
by SpiKe^^ » Tue Mar 15, 2022 8:15 pm
Try this...
Code: Select all
namespace eval radio {
variable streamurl "https://zenoplay.zenomedia.com/api/zenofm/nowplaying/ffvwrxpufzzuv"
variable radiochan "#yourchan"
variable radiodj "#yourchandj"
package require http
package require tls
variable cursong ""
bind pub - !direct ::radio::pub:getstream
bind pub -|n !mute ::radio::mute
bind pub -|n !unmute ::radio::unmute
proc mute {nick uhost handle chan text} {
if {![string equal -nocase $chan $::radio::radiodj]} { return 0 }
unbind cron - "* * * * *" ::radio::getstream
putserv "privmsg $::radio::radiodj :4parado los anuncios.."
}
proc unmute {nick uhost handle chan text} {
if {![string equal -nocase $chan $::radio::radiodj]} { return 0 }
bind cron - "* * * * *" ::radio::getstream
putserv "privmsg $::radio::radiodj :4Puesto en Automatico los anuncios.."
}
proc pub:getstream {nick uhost handle chan text} {
if {![string equal -nocase $chan $::radio::radiochan]} { return 0 }
::radio::getstream 0 0 0 0 "pub"
}
proc getstream {mi ho da mo wd} {
::http::register https 443 ::tls::socket
set tok [::http::geturl $::radio::streamurl]
set source [::radio::json2dict [::http::data $tok]]
::http::cleanup $tok
::http::unregister https
set title [dict get $source title]
set artist [dict get $source artist]
if {($wd eq "pub") || ($::radio::cursong ne $title)} {
set ::radio::cursong $title
set artist [encoding convertfrom utf-8 [string map {"&" "&"} $artist]]
set title [encoding convertfrom utf-8 [string map {"&" "&"} $title]]
putserv "PRIVMSG $::radio::radiochan :Ahora Suena : 3$title de 2$artist "
}
}
proc json2dict {JSONtext} {
string range [string trim [string trimleft [string map {\t {} \n {} \r {} , { } : { } \[ \{ \] \}} $JSONtext] {\uFEFF}]] 1 end-1
}
}
Last edited by
SpiKe^^ on Wed Mar 16, 2022 12:32 pm, edited 1 time in total.
flink
Halfop
Posts: 83 Joined: Sun Feb 21, 2021 9:27 am
Location: Canarias
Post
by flink » Wed Mar 16, 2022 7:30 am
Thanks for answering but now I can't test it. The chatzona gentlemen just gave me G-lined: Deactivate your browser's vpn to eggdrop and I can't test it, thanks for the help, I'm waiting for the chatzona gentlemen to give me some solution I doubt it anyway thanks
Mi ingles: no es el mejor, Manda el traductor...
flink
Halfop
Posts: 83 Joined: Sun Feb 21, 2021 9:27 am
Location: Canarias
Post
by flink » Wed Mar 16, 2022 10:01 am
after solving the problem with chatzona probe
what you told me and it doesn't work for me I get this error by partyline
Tcl error [:
:pub:getstream]: wrong # args: should be ":
:getstream mi ho da mo wd"
Mi ingles: no es el mejor, Manda el traductor...
CrazyCat
Revered One
Posts: 1306 Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:
Post
by CrazyCat » Wed Mar 16, 2022 10:15 am
The following line is false:
Must be:
Or another numeric value.
And the proc must be changed to use the value and not "pub"
flink
Halfop
Posts: 83 Joined: Sun Feb 21, 2021 9:27 am
Location: Canarias
Post
by flink » Wed Mar 16, 2022 11:04 am
good Crazy Cat thanks for contributing ideas I removed pub and it still doesn't work !direct
Mi ingles: no es el mejor, Manda el traductor...