mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-07 03:38:53 -05:00
[Streams] beam.pro -> mixer
This commit is contained in:
parent
1384fadffb
commit
1e17ed7654
@ -43,7 +43,7 @@ class Streams:
|
||||
self.bot = bot
|
||||
self.twitch_streams = dataIO.load_json("data/streams/twitch.json")
|
||||
self.hitbox_streams = dataIO.load_json("data/streams/hitbox.json")
|
||||
self.beam_streams = dataIO.load_json("data/streams/beam.json")
|
||||
self.mixer_streams = dataIO.load_json("data/streams/beam.json")
|
||||
self.picarto_streams = dataIO.load_json("data/streams/picarto.json")
|
||||
settings = dataIO.load_json("data/streams/settings.json")
|
||||
self.settings = defaultdict(dict, settings)
|
||||
@ -89,13 +89,13 @@ class Streams:
|
||||
await self.bot.say(embed=embed)
|
||||
|
||||
@commands.command()
|
||||
async def beam(self, stream: str):
|
||||
"""Checks if beam stream is online"""
|
||||
async def mixer(self, stream: str):
|
||||
"""Checks if mixer stream is online"""
|
||||
stream = escape_mass_mentions(stream)
|
||||
regex = r'^(https?\:\/\/)?(www\.)?(beam\.pro\/)'
|
||||
regex = r'^(https?\:\/\/)?(www\.)?(mixer\.com\/)'
|
||||
stream = re.sub(regex, '', stream)
|
||||
try:
|
||||
embed = await self.beam_online(stream)
|
||||
embed = await self.mixer_online(stream)
|
||||
except OfflineStream:
|
||||
await self.bot.say(stream + " is offline.")
|
||||
except StreamNotFound:
|
||||
@ -193,15 +193,15 @@ class Streams:
|
||||
|
||||
dataIO.save_json("data/streams/hitbox.json", self.hitbox_streams)
|
||||
|
||||
@streamalert.command(name="beam", pass_context=True)
|
||||
async def beam_alert(self, ctx, stream: str):
|
||||
"""Adds/removes beam alerts from the current channel"""
|
||||
@streamalert.command(name="mixer", pass_context=True)
|
||||
async def mixer_alert(self, ctx, stream: str):
|
||||
"""Adds/removes mixer alerts from the current channel"""
|
||||
stream = escape_mass_mentions(stream)
|
||||
regex = r'^(https?\:\/\/)?(www\.)?(beam\.pro\/)'
|
||||
regex = r'^(https?\:\/\/)?(www\.)?(mixer\.com\/)'
|
||||
stream = re.sub(regex, '', stream)
|
||||
channel = ctx.message.channel
|
||||
try:
|
||||
await self.beam_online(stream)
|
||||
await self.mixer_online(stream)
|
||||
except StreamNotFound:
|
||||
await self.bot.say("That stream doesn't exist.")
|
||||
return
|
||||
@ -211,7 +211,7 @@ class Streams:
|
||||
except OfflineStream:
|
||||
pass
|
||||
|
||||
enabled = self.enable_or_disable_if_active(self.beam_streams,
|
||||
enabled = self.enable_or_disable_if_active(self.mixer_streams,
|
||||
stream,
|
||||
channel)
|
||||
|
||||
@ -221,7 +221,7 @@ class Streams:
|
||||
else:
|
||||
await self.bot.say("Alert has been removed from this channel.")
|
||||
|
||||
dataIO.save_json("data/streams/beam.json", self.beam_streams)
|
||||
dataIO.save_json("data/streams/beam.json", self.mixer_streams)
|
||||
|
||||
@streamalert.command(name="picarto", pass_context=True)
|
||||
async def picarto_alert(self, ctx, stream: str):
|
||||
@ -261,7 +261,7 @@ class Streams:
|
||||
streams = (
|
||||
self.hitbox_streams,
|
||||
self.twitch_streams,
|
||||
self.beam_streams,
|
||||
self.mixer_streams,
|
||||
self.picarto_streams
|
||||
)
|
||||
|
||||
@ -279,7 +279,7 @@ class Streams:
|
||||
|
||||
dataIO.save_json("data/streams/twitch.json", self.twitch_streams)
|
||||
dataIO.save_json("data/streams/hitbox.json", self.hitbox_streams)
|
||||
dataIO.save_json("data/streams/beam.json", self.beam_streams)
|
||||
dataIO.save_json("data/streams/beam.json", self.mixer_streams)
|
||||
dataIO.save_json("data/streams/picarto.json", self.picarto_streams)
|
||||
|
||||
await self.bot.say("There will be no more stream alerts in this "
|
||||
@ -375,14 +375,14 @@ class Streams:
|
||||
else:
|
||||
raise APIError()
|
||||
|
||||
async def beam_online(self, stream):
|
||||
url = "https://beam.pro/api/v1/channels/" + stream
|
||||
async def mixer_online(self, stream):
|
||||
url = "https://mixer.com/api/v1/channels/" + stream
|
||||
|
||||
async with aiohttp.get(url) as r:
|
||||
data = await r.json(encoding='utf-8')
|
||||
if r.status == 200:
|
||||
if data["online"] is True:
|
||||
return self.beam_embed(data)
|
||||
return self.mixer_embed(data)
|
||||
else:
|
||||
raise OfflineStream()
|
||||
elif r.status == 404:
|
||||
@ -473,11 +473,11 @@ class Streams:
|
||||
embed.color = 0x98CB00
|
||||
return embed
|
||||
|
||||
def beam_embed(self, data):
|
||||
default_avatar = ("https://beam.pro/_latest/assets/images/main/"
|
||||
def mixer_embed(self, data):
|
||||
default_avatar = ("https://mixer.com/_latest/assets/images/main/"
|
||||
"avatars/default.jpg")
|
||||
user = data["user"]
|
||||
url = "https://beam.pro/" + data["token"]
|
||||
url = "https://mixer.com/" + data["token"]
|
||||
embed = discord.Embed(title=data["name"], url=url)
|
||||
embed.set_author(name=user["username"])
|
||||
embed.add_field(name="Followers", value=data["numFollowers"])
|
||||
@ -564,7 +564,7 @@ class Streams:
|
||||
|
||||
streams = ((self.twitch_streams, self.twitch_online),
|
||||
(self.hitbox_streams, self.hitbox_online),
|
||||
(self.beam_streams, self.beam_online),
|
||||
(self.mixer_streams, self.mixer_online),
|
||||
(self.picarto_streams, self.picarto_online))
|
||||
|
||||
for streams_list, parser in streams:
|
||||
@ -608,7 +608,7 @@ class Streams:
|
||||
if save:
|
||||
dataIO.save_json("data/streams/twitch.json", self.twitch_streams)
|
||||
dataIO.save_json("data/streams/hitbox.json", self.hitbox_streams)
|
||||
dataIO.save_json("data/streams/beam.json", self.beam_streams)
|
||||
dataIO.save_json("data/streams/beam.json", self.mixer_streams)
|
||||
dataIO.save_json("data/streams/picarto.json", self.picarto_streams)
|
||||
|
||||
await asyncio.sleep(CHECK_DELAY)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user