Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F665125
broadcast_handler.ex
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
broadcast_handler.ex
View Options
defmodule
LSG.IRC.BroadcastHandler
do
def
irc_doc
,
do
:
""
def
start_link
(
client
)
do
GenServer
.
start_link
(
__MODULE__
,
[
client
])
end
def
init
([
client
])
do
ExIRC.Client
.
add_handler
client
,
self
{
:ok
,
_
}
=
Registry
.
register
(
LSG.BroadcastRegistry
,
"icecast"
,
[])
{
:ok
,
{
client
,
[
"
#
lsg"
],
false
}}
end
def
handle_info
({
:icecast
,
stats
=
%{
live
:
true
}},
s
=
{
client
,
channels
,
true
})
do
for
c
<-
channels
do
ExIRC.Client
.
msg
(
client
,
:privmsg
,
c
,
"en direct: "
<>
format_genre
(
stats
.
genre
)
<>
stats
.
np
)
end
{
:noreply
,
s
}
end
def
handle_info
({
:icecast
,
stats
=
%{
live
:
true
}},
s
=
{
client
,
channels
,
false
})
do
for
c
<-
channels
do
ExIRC.Client
.
msg
(
client
,
:privmsg
,
c
,
"115ANS EN DIREK! "
<>
format_genre
(
stats
.
genre
)
<>
stats
.
np
)
end
{
:noreply
,
{
client
,
channels
,
true
}}
end
def
handle_info
({
:icecast
,
stats
=
%{
live
:
false
}},
s
=
{
client
,
channels
,
true
})
do
for
c
<-
channels
do
ExIRC.Client
.
msg
(
client
,
:privmsg
,
c
,
"Le direct c'est fini, retour aux Smashing Pumpkins..."
)
ExIRC.Client
.
msg
(
client
,
:privmsg
,
c
,
"np: "
<>
stats
.
np
)
end
{
:noreply
,
{
client
,
channels
,
false
}}
end
# Catch-all for messages you don't care about
def
handle_info
(
msg
,
state
)
do
{
:noreply
,
state
}
end
defp
format_genre
(
nil
),
do
:
""
defp
format_genre
(
""
),
do
:
""
defp
format_genre
(
text
),
do
:
"[
#{
text
}
] "
end
File Metadata
Details
Attached
Mime Type
text/x-ruby
Expires
Fri, Feb 27, 10:26 AM (1 d, 19 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
87170
Default Alt Text
broadcast_handler.ex (1 KB)
Attached To
rNOLA Nola
Event Timeline
Log In to Comment