-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.py
27 lines (22 loc) · 814 Bytes
/
utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import json
import requests
import logging
import glob
import twitch
def getChannels():
glob.c.execute("SELECT id, name FROM channels")
return glob.c.fetchall()
def getEvents(channel):
glob.c.execute("SELECT message, interval FROM events WHERE channel = ?", (channel,))
return glob.c.fetchall()
def getAllCommands(channel):
glob.c.execute("SELECT * FROM commands WHERE channel = ?", (channel,))
def isMod(username, channel):
r = requests.get("http://tmi.twitch.tv/group/user/{}/chatters".format(username))
if r.status_code != 200:
logging.error("Error getting list of mods")
js = r.json()
chatters = js["chatters"]
if username in chatters["broadcaster"] or username in chatters["moderators"] or username == "tryonelove":
return True
return False