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