Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
while(True):
r = requests.get(url, headers=headers)
latest = r.json()
chatters = []
for mod in latest['chatters']['moderators']:
chatters.append(mod)
for viewer in latest['chatters']['viewers']:
chatters.append(viewer)
for global_mod in latest['chatters']['global_mods']:
chatters.append(global_mod)
for admin in latest['chatters']['admins']:
chatters.append(admin)
for chatter in chatters:
chatterDbCheck = session.query(db_models.Chatter).filter(
db_models.Chatter.name == chatter).first()
if chatterDbCheck:
chatterDbCheck.currency += 1
chatterDbCheck.totalMinutes += 1
else:
newChatter = db_models.Chatter(
name = chatter,
currency = 1,
totalMinutes = 1,
follower = False)
session.add(newChatter)
session.commit()
print("New points doled out at: " , time.time())
time.sleep(60)
while(True):
r = requests.get(url, headers=headers)
latest = r.json()
chatters = []
for mod in latest['chatters']['moderators']:
chatters.append(mod)
for viewer in latest['chatters']['viewers']:
chatters.append(viewer)
for global_mod in latest['chatters']['global_mods']:
chatters.append(global_mod)
for admin in latest['chatters']['admins']:
chatters.append(admin)
for chatter in chatters:
chatterDbCheck = session.query(db_models.Chatter).filter(
db_models.Chatter.name == chatter).first()
if chatterDbCheck:
chatterDbCheck.currency += 1
chatterDbCheck.totalMinutes += 1
else:
newChatter = db_models.Chatter(
name = chatter,
currency = 1,
totalMinutes = 1,
follower = False)
session.add(newChatter)
session.commit()
print("New points doled out at: " , time.time())
time.sleep(60)
chatters.append(mod)
for viewer in latest['chatters']['viewers']:
chatters.append(viewer)
for global_mod in latest['chatters']['global_mods']:
chatters.append(global_mod)
for admin in latest['chatters']['admins']:
chatters.append(admin)
for chatter in chatters:
chatterDbCheck = session.query(db_models.Chatter).filter(
db_models.Chatter.name == chatter).first()
if chatterDbCheck:
chatterDbCheck.currency += 1
chatterDbCheck.totalMinutes += 1
else:
newChatter = db_models.Chatter(
name = chatter,
currency = 1,
totalMinutes = 1,
follower = False)
session.add(newChatter)
session.commit()
print("New points doled out at: " , time.time())
time.sleep(60)
def checkForNewFollower(channel, q_twitchbeagle, logger):
try:
followers = channels.getChannelFollowers(channel)
latestDisplay = followers["follows"][0]['user']['display_name'].encode(
'utf-8')
latestUsername = followers["follows"][0]['user']['name']
latestId = followers["follows"][0]['user']['_id']
print("FOLLOWCHECK", latestDisplay, latestUsername, latestId)
event = {
'eventType' : 'currency',
'event' : 'follower %d %s %s' %(latestId,
latestUsername, latestDisplay)
}
q_twitchbeagle.put(event)
except Exception,e:
logger.error(str(e))
logger.error(traceback.format_exc())
def react_chat_settitle(args):
config = ConfigParser.ConfigParser()
config.read('config.ini')
channelName = config.get('CHAT', 'channel')
channel = str(getChannelId(channelName))
setChannelTitle(channel, ' '.join(args))
def react_chat_setgame(args):
config = ConfigParser.ConfigParser()
config.read('config.ini')
channelName = config.get('CHAT', 'channel')
channel = str(getChannelId(channelName))
setChannelGame(channel, ' '.join(args))
import thread
import time
import json
import ConfigParser
from twitchapi.krakenv5.channels import getChannelId
from config import EDITOR_TOKEN
config = ConfigParser.ConfigParser()
config.read('config.ini')
pingDict = {
'type': 'PING'
}
channelId = str(getChannelId(config.get('CHAT', 'channel')))
listenDict = {
'type':"LISTEN",
'nonce':"twitchPubSub",
'data': {
'topics' : [
'chat_moderator_actions.' + channelId + '.' + channelId,
'channel-bits-events-v1.' + channelId,
'channel-subscribe-events-v1.' + channelId
],
'auth_token': EDITOR_TOKEN
}
}
def pubsub_handler(q_twitchbeagle, q_pubsub):
def react_chat_setgame(args):
config = ConfigParser.ConfigParser()
config.read('config.ini')
channelName = config.get('CHAT', 'channel')
channel = str(getChannelId(channelName))
setChannelGame(channel, ' '.join(args))
def react_chat_settitle(args):
config = ConfigParser.ConfigParser()
config.read('config.ini')
channelName = config.get('CHAT', 'channel')
channel = str(getChannelId(channelName))
setChannelTitle(channel, ' '.join(args))