How to use twitchAPI - 9 common examples

To help you get started, we’ve selected a few twitchAPI examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Amperture / twitch-sbc-integration / twitchapi / currency_handler.py View on Github external
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)
github Amperture / twitch-sbc-integration / twitchapi / currency_handler.py View on Github external
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)
github Amperture / twitch-sbc-integration / twitchapi / currency_handler.py View on Github external
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)
github Amperture / twitch-sbc-integration / twitchapi / twitchapirun.py View on Github external
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())
github Amperture / twitch-sbc-integration / twitchapi / commands / settitle.py View on Github external
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))
github Amperture / twitch-sbc-integration / twitchapi / commands / setgame.py View on Github external
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))
github Amperture / twitch-sbc-integration / pubsub / pubsubrun.py View on Github external
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):
github Amperture / twitch-sbc-integration / twitchapi / commands / setgame.py View on Github external
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))
github Amperture / twitch-sbc-integration / twitchapi / commands / settitle.py View on Github external
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))

twitchAPI

A Python 3.7+ implementation of the Twitch Helix API, PubSub, EventSub and Chat

MIT
Latest version published 3 months ago

Package Health Score

70 / 100
Full package analysis

Similar packages