Added a method to check if a channel is online
This commit is contained in:
parent
467fc40797
commit
ebc6ea4393
|
@ -3,8 +3,15 @@ from .utils import config
|
|||
import urllib.request
|
||||
import urllib.parse
|
||||
import discord
|
||||
import json
|
||||
import re
|
||||
|
||||
def channelOnline(channel: str):
|
||||
url = "https://api.twitch.tv/kraken/streams/{}".format(channel)
|
||||
response = urllib.request.urlopen(url)
|
||||
data = json.loads(response.read().decode('utf-8'))
|
||||
return data['stream'] is not None
|
||||
|
||||
class Twitch:
|
||||
"""Class for some twitch integration"""
|
||||
def __init__(self, bot):
|
||||
|
|
Loading…
Reference in a new issue