mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-07 03:38:53 -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 __main__ import send_cmd_help
|
||||
import os
|
||||
import re
|
||||
import time
|
||||
import aiohttp
|
||||
import asyncio
|
||||
@ -28,6 +29,8 @@ class Streams:
|
||||
async def hitbox(self, stream: str):
|
||||
"""Checks if hitbox stream is online"""
|
||||
stream = escape_mass_mentions(stream)
|
||||
regex = r'^(https?\:\/\/)?(www\.)?(hitbox\.tv\/)'
|
||||
stream = re.sub(regex, '', stream)
|
||||
online = await self.hitbox_online(stream)
|
||||
if online is True:
|
||||
await self.bot.say("http://www.hitbox.tv/{}/"
|
||||
@ -43,6 +46,8 @@ class Streams:
|
||||
async def twitch(self, ctx, stream: str):
|
||||
"""Checks if twitch stream is online"""
|
||||
stream = escape_mass_mentions(stream)
|
||||
regex = r'^(https?\:\/\/)?(www\.)?(twitch\.tv\/)'
|
||||
stream = re.sub(regex, '', stream)
|
||||
online = await self.twitch_online(stream)
|
||||
if online is True:
|
||||
await self.bot.say("http://www.twitch.tv/{} "
|
||||
@ -62,6 +67,8 @@ class Streams:
|
||||
async def beam(self, stream: str):
|
||||
"""Checks if beam stream is online"""
|
||||
stream = escape_mass_mentions(stream)
|
||||
regex = r'^(https?\:\/\/)?(www\.)?(beam\.pro\/)'
|
||||
stream = re.sub(regex, '', stream)
|
||||
online = await self.beam_online(stream)
|
||||
if online is True:
|
||||
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):
|
||||
"""Adds/removes twitch alerts from the current channel"""
|
||||
stream = escape_mass_mentions(stream)
|
||||
regex = r'^(https?\:\/\/)?(www\.)?(twitch\.tv\/)'
|
||||
stream = re.sub(regex, '', stream)
|
||||
channel = ctx.message.channel
|
||||
check = await self.twitch_online(stream)
|
||||
if check == 404:
|
||||
@ -132,6 +141,8 @@ class Streams:
|
||||
async def hitbox_alert(self, ctx, stream: str):
|
||||
"""Adds/removes hitbox alerts from the current channel"""
|
||||
stream = escape_mass_mentions(stream)
|
||||
regex = r'^(https?\:\/\/)?(www\.)?(hitbox\.tv\/)'
|
||||
stream = re.sub(regex, '', stream)
|
||||
channel = ctx.message.channel
|
||||
check = await self.hitbox_online(stream)
|
||||
if check is None:
|
||||
@ -176,6 +187,8 @@ class Streams:
|
||||
async def beam_alert(self, ctx, stream: str):
|
||||
"""Adds/removes beam alerts from the current channel"""
|
||||
stream = escape_mass_mentions(stream)
|
||||
regex = r'^(https?\:\/\/)?(www\.)?(beam\.pro\/)'
|
||||
stream = re.sub(regex, '', stream)
|
||||
channel = ctx.message.channel
|
||||
check = await self.beam_online(stream)
|
||||
if check is None:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user