def test_logged_in_successful(): """ Test TwitchChatStream._logged_in_successful """ from twitchstream.chat import TwitchChatStream res = TwitchChatStream._logged_in_successful( ":tmi.twitch.tv NOTICE * :Error logging in") assert res is False res = TwitchChatStream._logged_in_successful( ":tmi.twitch.tv NOTICE * :Error logging in\n") assert res is False res = TwitchChatStream._logged_in_successful( ":tmi.twitch.tv NOTICE * :Error logging in\r\n") assert res is False res = TwitchChatStream._logged_in_successful( ":tmi.twitch.tv 001 sdsd :Welcome, GLHF!") assert res is True res = TwitchChatStream._logged_in_successful( ":tmi.twitch.tv 001 sdsd :Your host is tmi.twitch.tv") assert res is True res = TwitchChatStream._logged_in_successful( ":tmi.twitch.tv 001 sdsd :This server is rather new") assert res is True res = TwitchChatStream._logged_in_successful( ":tmi.twitch.tv 001 sdsd :-!") assert res is True res = TwitchChatStream._logged_in_successful( ":tmi.twitch.tv 001 sdsd :You are in a maze of twisty passages," " all alike.") assert res is True res = TwitchChatStream._logged_in_successful( ":tmi.twitch.tv 001 sdsd :>") assert res is True
def test_logged_in_successful(): """ Test TwitchChatStream._logged_in_successful """ from twitchstream.chat import TwitchChatStream res = TwitchChatStream._logged_in_successful( ":tmi.twitch.tv NOTICE * :Error logging in") assert res is False res = TwitchChatStream._logged_in_successful( ":tmi.twitch.tv NOTICE * :Error logging in\n") assert res is False res = TwitchChatStream._logged_in_successful( ":tmi.twitch.tv NOTICE * :Error logging in\r\n") assert res is False res = TwitchChatStream._logged_in_successful( ":tmi.twitch.tv 001 sdsd :Welcome, GLHF!") assert res is True res = TwitchChatStream._logged_in_successful( ":tmi.twitch.tv 001 sdsd :Your host is tmi.twitch.tv") assert res is True res = TwitchChatStream._logged_in_successful( ":tmi.twitch.tv 001 sdsd :This server is rather new") assert res is True res = TwitchChatStream._logged_in_successful(":tmi.twitch.tv 001 sdsd :-!") assert res is True res = TwitchChatStream._logged_in_successful( ":tmi.twitch.tv 001 sdsd :You are in a maze of twisty passages," " all alike.") assert res is True res = TwitchChatStream._logged_in_successful(":tmi.twitch.tv 001 sdsd :>") assert res is True
def voting(number): conn = db_connect.connect() query = conn.execute("select * from questions where id = %d" % int(number)) for row in query: DisplayQuestion = row[0] OptionOne = row[1] OptionTwo = row[2] scoreA = 0 scoreB = 0 with TwitchChatStream(username='******', oauth='oauth:v1exdo5jw9hmqrbozduymby6opyn6w', verbose=False) as chatstream: chatstream.send_chat_message('Voting is open! Type A to vote for ', OptionOne, ' or type B to vote for ', OptionTwo, '.') timer = 60 while timer > 0: time.sleep(1) received = chatstream.twitch_receive_messages() if received: if chat_message['message'].lower() == 'a': scoreA += 1 if chat_message['message'].lower() == 'b': scoreB += 1 timer -= 1 result = {"OptionA": scoreA, "OptionB": scoreB} return jsonify(result)
def __init__(self): self.myToken = 'oauth:' + TwitchToken self.myUsername = TwitchUsername # Launch a verbose (!) twitch stream with TwitchChatStream(username=self.myUsername, oauth=self.myToken, verbose=True) as chatstream: self.chat = chatstream self.sendMessage("I'm ready to explore!")
def voting(): Quas = 0 Wex = 0 Exort = 0 with TwitchChatStream(username='******', oauth='oauth:v1exdo5jw9hmqrbozduymby6opyn6w', verbose=False) as chatstream: chatstream.send_chat_message('Voting for action has begun.') timer = 60 while timer > 0: time.sleep(1) received = chatstream.twitch_receive_messages() if received: if chat_message['message'].lower() == 'q': Quas += 1 if chat_message['message'].lower() == 'w': Wex += 1 if chat_message['message'].lower() == 'e': Exort += 1 timer -= 1 result = {"Quas": Quas, "Wex": Wex, "Exort": Exort} return jsonify(result)
help='twitch username', required=True) required.add_argument('-o', '--oauth', help='twitch oauth ' '(visit https://twitchapps.com/tmi/ ' 'to create one for your account)', required=False) args = parser.parse_args() if not args.oauth: f = open("oauth.properties", "r") auth = f.read() # Launch a verbose (!) twitch stream with TwitchChatStream(username=args.username, oauth=auth, verbose=True) as chatstream: chatstream.join_channel('existentiallyyours') # Send a message to this twitch stream for x in range(10): chatstream.send_chat_message("Oh Hello -"+ str(x) + "\r\n") # Continuously check if messages are received (every ~10s) # This is necessary, if not, the chat stream will close itself # after a couple of minutes (due to ping messages from twitch) while True: received = chatstream.twitch_receive_messages() if received: print("received:", received) time.sleep(1)
help='twitch streamkey', required=True) args = parser.parse_args() # load two streams: # * one stream to send the video # * one stream to interact with the chat with TwitchBufferedOutputStream( twitch_stream_key=args.streamkey, width=640, height=480, fps=30., enable_audio=True, verbose=False) as videostream, \ TwitchChatStream( username=args.username, oauth=args.oauth, verbose=False) as chatstream: # Send a chat message to let everybody know you've arrived chatstream.send_chat_message("Taking requests!") frame = np.zeros((480, 640, 3)) frequency = 100 last_phase = 0 # The main loop to create videos while True: # Every loop, call to receive messages. # This is important, when it is not called, # Twitch will automatically log you out.
x = int(splits[1]) y = int(splits[2]) print('intense: '+str(state)+' at: '+str(x)+' '+str(y)) display.update_pos(state,x,y) display.show_grid() chatstream.send_chat_message("Okay!") if __name__ == "__main__": myToken = 'oauth:'+TwitchToken myUsername = TwitchUsername # Launch a verbose (!) twitch stream with TwitchChatStream(username=myUsername, oauth=myToken, verbose=True) as chatstream: # Send a message to this twitch stream chatstream.send_chat_message("I'm reading this!") # Continuously check if messages are received (every ~10s) # This is necessary, if not, the chat stream will close itself # after a couple of minutes (due to ping messages from twitch) while True: received = chatstream.twitch_receive_messages() if received: #print("received:", received) for dictMessage in received: check_if_cmd(dictMessage) time.sleep(1)
from twitchstream.chat import TwitchChatStream chatstream = TwitchChatStream(username='******',oauth='oauth:7q0ihza8o2ftdm6xl8e20yl3kxtdgs',verbose=True) chatstream.send_chat_message('fuckl') while True: received = chatstream.twitch_receive_messages() if received: for chat_message in received: print("Got a message '%s' from %s" % ( chat_message['message'], chat_message['username'] ))
#!flask/bin/python # -*- coding: utf-8 -*- from flask import Flask, jsonify, abort, make_response, request, redirect, url_for, send_from_directory from flask_cors import CORS, cross_origin from twitchstream.chat import TwitchChatStream import threading import time #Add username & oauth key to make it work # --------------------- twitch connection -------------------------- twitch = TwitchChatStream(username='', oauth="oauth: ".encode()) twitch.connect() twitch.join_channel("nightblue3") twitch.join_channel("handiofiblood") #twitch.twitch_receive_messages() history = {} with open('updated_emoji.txt') as input_file: emoji_list = [] for line in input_file: line = line.strip() emoji_list.append(line) with open('emotion_from_emoji.txt') as input_file: emotion_list = [] for line in input_file: line = line.strip() emotion_list.append(line)
if __name__ == "__main__": game = Game() game.reset() # load two streams, one for video one for chat with TwitchBufferedOutputStream( twitch_stream_key=streaminfo.STREAMKEY, width=640, height=480, fps=30., enable_audio=False, verbose=False) as videostream, \ TwitchChatStream( username=streaminfo.USERNAME, oauth=streaminfo.OAUTH, verbose=False) as chatstream: chatstream.send_chat_message('connecting to chat...') print('connected to chat...') # main loop while True: # Every loop, call to receive messages. # This is important, when it is not called, # Twitch will automatically log you out. # This call is non-blocking. chat_messages = chatstream.twitch_receive_messages() # process messages if chat_messages:
help='twitch streamkey', required=True) args = parser.parse_args() # load two streams: # * one stream to send the video # * one stream to interact with the chat with TwitchBufferedOutputStream( twitch_stream_key=args.streamkey, width=640, height=480, fps=30., enable_audio=True, verbose=False) as videostream, \ TwitchChatStream( username=args.username.lower(), # Must provide a lowercase username. oauth=args.oauth, verbose=False) as chatstream: # Send a chat message to let everybody know you've arrived chatstream.send_chat_message("Taking requests!") frame = np.zeros((480, 640, 3)) frequency = 100 last_phase = 0 # The main loop to create videos while True: # Every loop, call to receive messages. # This is important, when it is not called, # Twitch will automatically log you out.