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.

how to centralize the commands only in a room

Help for those learning Tcl or writing their own scripts.
User avatar
flink
Halfop
Posts: 83
Joined: Sun Feb 21, 2021 9:27 am
Location: Canarias

how to centralize the commands only in a room

Post by flink »

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... :)
User avatar
CrazyCat
Revered One
Posts: 1306
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

Not sure to understand your trouble. Which command must be used in which channel with which effect ?
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Make !mute and !unmute commands channel specific.

Post by SpiKe^^ »

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.
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
User avatar
flink
Halfop
Posts: 83
Joined: Sun Feb 21, 2021 9:27 am
Location: Canarias

Post by flink »

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... :)
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

Now you have both of us very confused.

Please try to explain what you are after here...
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
User avatar
flink
Halfop
Posts: 83
Joined: Sun Feb 21, 2021 9:27 am
Location: Canarias

Post by flink »

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... :)
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

Slightly changed the above fix I posted.

You need to .restart the bot to remove all earlier binds!
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
User avatar
flink
Halfop
Posts: 83
Joined: Sun Feb 21, 2021 9:27 am
Location: Canarias

Post by flink »

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... :)
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

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?
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
User avatar
flink
Halfop
Posts: 83
Joined: Sun Feb 21, 2021 9:27 am
Location: Canarias

Post by flink »

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... :)
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

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.
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
User avatar
flink
Halfop
Posts: 83
Joined: Sun Feb 21, 2021 9:27 am
Location: Canarias

Post by flink »

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... :)
User avatar
flink
Halfop
Posts: 83
Joined: Sun Feb 21, 2021 9:27 am
Location: Canarias

Post by flink »

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 [::radio::pub:getstream]: wrong # args: should be "::radio::getstream mi ho da mo wd"
Mi ingles: no es el mejor, Manda el traductor... :)
User avatar
CrazyCat
Revered One
Posts: 1306
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

The following line is false:

Code: Select all

::radio::getstream 0 0 0 0 pub
Must be:

Code: Select all

::radio::getstream 0 0 0 0 0
Or another numeric value.
And the proc must be changed to use the value and not "pub"
User avatar
flink
Halfop
Posts: 83
Joined: Sun Feb 21, 2021 9:27 am
Location: Canarias

Post by flink »

good Crazy Cat thanks for contributing ideas I removed pub and it still doesn't work !direct

Code: Select all

::radio::getstream 0 0 0 0 0
Mi ingles: no es el mejor, Manda el traductor... :)
Post Reply