def getCurrentChats(channel): #Enter your twitch username and oauth-key below, and the app connects to twitch with the details. #Your oauth-key can be generated at http://twitchapps.com/tmi/ username = "******" key = "oauth:i8toc6nn173v4kxneqh2cup0563dbk" t = twitch.Twitch() t.twitch_connect(username, key, channel) #The main loop count = 0 while True: #Check for new mesasages new_messages = t.twitch_recieve_messages() if count == 50: count = 0 query.retrieveAndCount(channel, None) if not new_messages: #No new messages... continue else: for message in new_messages: #Wuhu we got a message. Let's extract some details from it msg = message['message'] username = message['username'] result = fb.post(channel, { "name": username, "message": msg, }) print "%s inserted to database" % msg count += 1
def __init__(self): self.default_position_increment = rospy.get_param( "~default_position_increment", 10) self.default_angle_increment = rospy.get_param( "~default_angle_increment", 15) self.side = rospy.get_param("~side", "left") self.invert = rospy.get_param("~invert", False) if self.invert is True: if self.side == "left": self.side = "right" elif self.side == "right": self.side = "left" oa_key = rospy.get_param("~oa_key") username = rospy.get_param("~username") self.t = twitch.Twitch() self.t.twitch_connect(username, oa_key) # 3DOF position end effector changing self.delta_pos = [0] * 3 # final wrist joint angle changing self.delta_wrist = 0 # close and open the grippers self.button = 0 node_name = "tpb_" + self.side + "_vt" rospy.init_node(node_name, anonymous=True) self.r = rospy.Rate(20) # 20hz rospy.wait_for_service("/" + node_name + "/move_request") self.move_service_client = rospy.ServiceProxy( "/" + node_name + "/move_request", TPBMove)
def __init__(self): t = twitch.Twitch() t.set(config.username, config.key, config.room) t.connect() t.join() self.t = t self.inputbuffer = [sys.stdin, t.s]
async def add_test_messages_t(self): import twitch t = twitch.Twitch('sle') m = dict(id='t', name='chaos_soft', color='#ff69b4', text='-t от root') MESSAGES.append(m.copy()) m['text'] = '-i https://gals.kindgirls.com/d009/ariel_25530/ariel_25530_2.jpg' MESSAGES.append(m.copy()) m['text'] = '<] >( ;) #/ <3 <3 <3 xxx <3 <3 <3' m['emotes'] = '555555562:3-4/555555589:6-7/555555584:12-13,15-16,18-19,25-26,28-29,31-32' await t.parse_emotes(m) MESSAGES.append(m.copy()) m['text'] = 'LUL ResidentSleeper SeriousSloth' m['emotes'] = '425618:0-2/245:4-18/81249:20-31' await t.parse_emotes(m) MESSAGES.append(m.copy())
def __init__(self): # import keypresser self.t = twitch.Twitch() # k = keypresser.Keypresser(); #Enter your twitch username and oauth-key below, and the app connects to twitch with the details. #Your oauth-key can be generated at http://twitchapps.com/tmi/ username = "******" key = "oauth:2upqjc2h4vzy1qlpuiq27l9evewpye" self.t.twitch_connect(username, key) self.count = Counter() self.lock = threading.Lock() self.moves = ("buy", "sell", "switch") self.stop = False def update(): #The main loop while not self.stop: time.sleep(5) print 'getting comments' #Check for new mesasages new_messages = self.t.twitch_receive_messages() print "MSG", new_messages if not new_messages: #No new messages... continue else: for message in new_messages: print "MSG_", message #Wuhu we got a message. Let's extract some details from it msg = message['message'].lower() #username = message['username'].lower() print msg with self.lock: for move in self.moves: if move in msg: self.count[move] += 1 #print(username + ": " + msg); self.thread = threading.Thread(target=update) self.thread.start()
async def main() -> None: async with aiohttp.ClientSession() as session: TASKS.append(asyncio.create_task(server.Server().main())) if 'commands' in CONFIG: import commands TASKS.append(asyncio.create_task(commands.Commands().main())) if 'goodgame' in CONFIG: import goodgame for channel in CONFIG['goodgame'].getlist('channels'): TASKS.append( asyncio.create_task( goodgame.GoodGame(channel).main(session))) if 'peka2tv' in CONFIG: import peka2tv for channel in CONFIG['peka2tv'].getlist('channels'): p = peka2tv.Peka2tv(channel) TASKS.append(asyncio.create_task(p.main(session))) TASKS.append(asyncio.create_task(p.send_heartbeat())) if 'twitch' in CONFIG: import twitch channels = CONFIG['twitch'].getlist('channels') for channel in channels: TASKS.append( asyncio.create_task(twitch.Twitch(channel).main(session))) if channels.index(channel) == 0: if CONFIG['twitch'].getboolean('is_follows'): TASKS.append( asyncio.create_task( twitch.get_channel_id(channel))) TASKS.append( asyncio.create_task( twitch.TwitchFollows(channel).main())) if CONFIG['twitch'].getboolean('is_stats'): TASKS.append( asyncio.create_task( twitch.TwitchStats(channel).main())) if 'wasd' in CONFIG: import wasd w = wasd.WASD(CONFIG['wasd'].getint('channel')) TASKS.append(asyncio.create_task(w.main(session))) TASKS.append(asyncio.create_task(w.send_heartbeat())) await asyncio.gather(*TASKS)
#!/usr/bin/env python # -*- coding: utf-8 -*- #Define the imports import twitch # import keypresser t = twitch.Twitch() # k = keypresser.Keypresser(); #Enter your twitch username and oauth-key below, and the app connects to twitch with the details. #Your oauth-key can be generated at http://twitchapps.com/tmi/ username = "******" key = "oauth:uqxggjb5i1iqd57dickc794iz7rn46" t.twitch_connect(username, key) #The main loop while True: #Check for new mesasages new_messages = t.twitch_receive_messages() if not new_messages: #No new messages... continue else: for message in new_messages: #Wuhu we got a message. Let's extract some details from it msg = message['message'].lower() username = message['username'].lower() print(username + ": " + msg) #This is where you change the keys that shall be pressed and listened to.
def connect(self): self.tw = twitch.Twitch() self.tw.twitch_connect(self.twitch_username, self.twitch_key) self.oc = octoApi.OctoApi(self.octopi_ip, self.octopi_key)
#Discord Twitch Bot import discord import itertools from discord.ext import commands import discord.utils from twitch_lib import TwitchAPI import twitch import game bot = commands.Bot(command_prefix='?') @bot.event async def on_ready(): await bot.change_presence(activity=discord.Game('?info for commands')) print(f'Logged in as: {bot.user.name}') print(f'With ID: {bot.user.id}') bot.add_cog(twitch.Twitch(bot)) bot.add_cog(game.Game(bot)) with open('BOT_TOKEN.txt', 'r') as f: bot.run(f.read().strip())
if len(sys.argv) != 3: print("Invalid command line arguments. Please provide username and key (http://twitchapps.com/tmi/).") sys.exit() username = sys.argv[1] key = sys.argv[2] # http://twitchapps.com/tmi/ ignoreMessagesOfOthers = False pyautogui.FAILSAFE = True ############################################################################## # TWITCH, THREAD ############################################################################## messageQueue = queue.Queue() twitchObj = twitch.Twitch() def twitchThreadFunction(): while 1: newMessages = twitchObj.receiveMessages() if newMessages: messageQueue.put(newMessages) time.sleep(0.001) twitchThread = threading.Thread(target=twitchThreadFunction) twitchThread.daemon = True ############################################################################## # GO LIVE ##############################################################################
#Define the imports import twitch import logging import normalMode import violenceMode import time import datetime import keypresser keypresser = keypresser.keyPresser() violence = violenceMode.violenceMode() normal = normalMode.normalMode() twitch = twitch.Twitch() logging.basicConfig(filename='commands.log', level=logging.INFO, format='%(asctime)s - %(message)s', datefmt='%Y/%m/%d %I:%M:%S') gameStart = True gameMode = 'normal' normalMode = 'normal' democracyMode = 'democracy' violenceMode = 'violence' startTime = datetime.datetime.now() waitTime = 3 cacheCommand = [] lastRecvTime = startTime newMessages = '' #Enter your twitch username and oauth-key below, and the app connects to twitch with the details. #Your oauth-key can be generated at http://twitchapps.com/tmi/ usr = '******'