mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-07 11:48:55 -05:00
[Streams] Handle both channel names and URLs (#575)
This commit is contained in:
parent
416e168d2b
commit
438d9f5f60
@ -5,6 +5,7 @@ from .utils.chat_formatting import *
|
|||||||
from .utils import checks
|
from .utils import checks
|
||||||
from __main__ import send_cmd_help
|
from __main__ import send_cmd_help
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
import time
|
import time
|
||||||
import aiohttp
|
import aiohttp
|
||||||
import asyncio
|
import asyncio
|
||||||
@ -28,6 +29,8 @@ class Streams:
|
|||||||
async def hitbox(self, stream: str):
|
async def hitbox(self, stream: str):
|
||||||
"""Checks if hitbox stream is online"""
|
"""Checks if hitbox stream is online"""
|
||||||
stream = escape_mass_mentions(stream)
|
stream = escape_mass_mentions(stream)
|
||||||
|
regex = r'^(https?\:\/\/)?(www\.)?(hitbox\.tv\/)'
|
||||||
|
stream = re.sub(regex, '', stream)
|
||||||
online = await self.hitbox_online(stream)
|
online = await self.hitbox_online(stream)
|
||||||
if online is True:
|
if online is True:
|
||||||
await self.bot.say("http://www.hitbox.tv/{}/"
|
await self.bot.say("http://www.hitbox.tv/{}/"
|
||||||
@ -43,6 +46,8 @@ class Streams:
|
|||||||
async def twitch(self, ctx, stream: str):
|
async def twitch(self, ctx, stream: str):
|
||||||
"""Checks if twitch stream is online"""
|
"""Checks if twitch stream is online"""
|
||||||
stream = escape_mass_mentions(stream)
|
stream = escape_mass_mentions(stream)
|
||||||
|
regex = r'^(https?\:\/\/)?(www\.)?(twitch\.tv\/)'
|
||||||
|
stream = re.sub(regex, '', stream)
|
||||||
online = await self.twitch_online(stream)
|
online = await self.twitch_online(stream)
|
||||||
if online is True:
|
if online is True:
|
||||||
await self.bot.say("http://www.twitch.tv/{} "
|
await self.bot.say("http://www.twitch.tv/{} "
|
||||||
@ -62,6 +67,8 @@ class Streams:
|
|||||||
async def beam(self, stream: str):
|
async def beam(self, stream: str):
|
||||||
"""Checks if beam stream is online"""
|
"""Checks if beam stream is online"""
|
||||||
stream = escape_mass_mentions(stream)
|
stream = escape_mass_mentions(stream)
|
||||||
|
regex = r'^(https?\:\/\/)?(www\.)?(beam\.pro\/)'
|
||||||
|
stream = re.sub(regex, '', stream)
|
||||||
online = await self.beam_online(stream)
|
online = await self.beam_online(stream)
|
||||||
if online is True:
|
if online is True:
|
||||||
await self.bot.say("https://beam.pro/{} is online!".format(stream))
|
await self.bot.say("https://beam.pro/{} is online!".format(stream))
|
||||||
@ -83,6 +90,8 @@ class Streams:
|
|||||||
async def twitch_alert(self, ctx, stream: str):
|
async def twitch_alert(self, ctx, stream: str):
|
||||||
"""Adds/removes twitch alerts from the current channel"""
|
"""Adds/removes twitch alerts from the current channel"""
|
||||||
stream = escape_mass_mentions(stream)
|
stream = escape_mass_mentions(stream)
|
||||||
|
regex = r'^(https?\:\/\/)?(www\.)?(twitch\.tv\/)'
|
||||||
|
stream = re.sub(regex, '', stream)
|
||||||
channel = ctx.message.channel
|
channel = ctx.message.channel
|
||||||
check = await self.twitch_online(stream)
|
check = await self.twitch_online(stream)
|
||||||
if check == 404:
|
if check == 404:
|
||||||
@ -132,6 +141,8 @@ class Streams:
|
|||||||
async def hitbox_alert(self, ctx, stream: str):
|
async def hitbox_alert(self, ctx, stream: str):
|
||||||
"""Adds/removes hitbox alerts from the current channel"""
|
"""Adds/removes hitbox alerts from the current channel"""
|
||||||
stream = escape_mass_mentions(stream)
|
stream = escape_mass_mentions(stream)
|
||||||
|
regex = r'^(https?\:\/\/)?(www\.)?(hitbox\.tv\/)'
|
||||||
|
stream = re.sub(regex, '', stream)
|
||||||
channel = ctx.message.channel
|
channel = ctx.message.channel
|
||||||
check = await self.hitbox_online(stream)
|
check = await self.hitbox_online(stream)
|
||||||
if check is None:
|
if check is None:
|
||||||
@ -176,6 +187,8 @@ class Streams:
|
|||||||
async def beam_alert(self, ctx, stream: str):
|
async def beam_alert(self, ctx, stream: str):
|
||||||
"""Adds/removes beam alerts from the current channel"""
|
"""Adds/removes beam alerts from the current channel"""
|
||||||
stream = escape_mass_mentions(stream)
|
stream = escape_mass_mentions(stream)
|
||||||
|
regex = r'^(https?\:\/\/)?(www\.)?(beam\.pro\/)'
|
||||||
|
stream = re.sub(regex, '', stream)
|
||||||
channel = ctx.message.channel
|
channel = ctx.message.channel
|
||||||
check = await self.beam_online(stream)
|
check = await self.beam_online(stream)
|
||||||
if check is None:
|
if check is None:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user