Beispiel #1
0
def main():
    helix = twitch.Helix('', use_cache=True)
    global lastmsg, msg
    lastmsg = datetime.datetime.now()
    msg = queue.Queue(100)
    sess = gpt2.start_tf_sess()
    gpt2.load_gpt2(sess, run_name=run_name)

    while not msg.full():
        newmsg = genmsg(sess)
        print(newmsg)
        msg.put(newmsg)

    for channel in textchannels:
        chat = twitch.Chat(channel="#" + channel,
                           nickname='WoodenLongboard',
                           oauth="",
                           helix=helix)
        chats[channel] = chat
        chats[channel].subscribe(handle_message)

    print("Finished init")

    while True:
        if not msg.full():
            msg.put(genmsg(sess))
Beispiel #2
0
def twitchLive():
    # helix = twitch.Helix(client_id=Config.TWITCH_CLIENT_ID,
    #                      use_cache=True,
    #                      bearer_token=Config.TWITCH_BEARER_TOKEN)
    twitch.Chat(channel=Config.TWITCH_CHANNEL,
                nickname=Config.TWITCH_NICKNAME,
                oauth=Config.TWITCH_OAUTH_TOKEN).subscribe(
                    lambda message: twitchChat(message))
Beispiel #3
0
 def __init__(self, channel):
     self.chat = twitch.Chat(channel=channel,
                             nickname='bot',
                             oauth='oauth:la6kj4pn3vzfdvvkfrg8y5eqvbuxjk',
                             helix=twitch.Helix(
                                 client_id='hqiwd4o8a3mf6l7t7l0xge8qt7ksob',
                                 use_cache=True))
     self.chat.subscribe(handle_message)
Beispiel #4
0
 def assign_core(self, core):
     if not self.enabled:
         return False
     super().assign_core(core)
     self.helix = twitch.Helix('jqqxdo6tewc80vot6w66mkzfnso558',
                               '7tsxcnw9efuxbjk3q2r8ebdx54k01c')
     self.chat = twitch.Chat(channel='#cheeseypi',
                             nickname='cheeseyquichebot',
                             oauth='oauth:948piogkdqxbti42c8pwu0grd5zily',
                             helix=self.helix)
     self.chat.subscribe((lambda message: self.receivedMessage(message)))
     return True
Beispiel #5
0
    def __init__(self, channel):#api:webhook.api):
        self.channel = channel
        # self.api = api
        # self._id = self.api.user_id(channel) #la6kj4pn3vzfdvvkfrg8y5eqvbuxjk   qxhcdwsgg5m3qm7or17f3lo51soznk
        # self.api.sub_streamchange(self._id)

        self.helix=twitch.Helix(client_id='hqiwd4o8a3mf6l7t7l0xge8qt7ksob', use_cache=True)
        self.chat = twitch.Chat(channel=channel,
                       nickname='bot',
                       oauth='oauth:la6kj4pn3vzfdvvkfrg8y5eqvbuxjk',
                       helix=self.helix)
        self.buf = []
Beispiel #6
0
def main():
    # pdb.set_trace()
    chat = twitch.Chat(
        channel='isaiahmonday',  # adjust this for your channel name
        nickname='bot',

        # awd contains an oauth key which is not shared publicly. Create your own awd.txt file
        oauth=open("awd.txt").read(),

        # adjust this for your client ID
        helix=twitch.Helix(client_id='lmpf9a1btnphwvvy879gqly1voc4ak',
                           use_cache=True))

    chat.subscribe(handle_message)
    app.run()
Beispiel #7
0
 def start(self):
     for _, channel in utils.getChannels():
         self.active_chats[channel] = twitch.Chat(
             channel='#{}'.format(channel),
             nickname=config.BOT_NAME,
             oauth=config.OAUTH_TOKEN,
             helix=twitch.Helix(client_id=config.CLIENT_ID, use_cache=True))
         self.active_chats[channel].subscribe(self.messageHandler)
         events = utils.getEvents(channel)
         glob.events[channel] = eventHandler.MessagePoster(
             chat=self.active_chats[channel])
         for message, interval in events:
             glob.events[channel].addEvent(message, interval)
         logging.info("JOINED #{}".format(channel))
     logging.info("Succesfully started")
Beispiel #8
0
def main():
    #Initialize Tank
    my_tank.gimbal_x_angle = 90
    my_tank.gimbal_y_angle = 90
    my_tank.gimbal_y(0)
    my_tank.gimbal_x(0)

    #First lets get our oauth2 key from a local file
    with open("twitch_oauth2", 'r') as f:
        oauth2_code = f.read()
        f.close()  #Be sure to clean up

    #Connect to twitch chat
    twitch.Chat(channel='#smurf_codes',
                nickname='smurf_codes',
                oauth=f"oauth:{oauth2_code}").subscribe(
                    lambda message: check_chat(message))
Beispiel #9
0
    def join_channel(self, credential: credentials.Twitch_Credential, channel_name: str):
        channel_name = "#" + channel_name
        print("Connecting to Channel: " + channel_name + "...")

        if credential is None:
            credential = self.twitchCredential

        self.chat = twitch.Chat(
            channel=channel_name,
            nickname=credential.username,
            oauth=credential.oauth,
            # LIBRARY UPDATE BROKE THE FOLLOWING LINE [FIX THIS]
            # helix = twitch.Helix(credential.helix, use_cache=True)
        )
        self.chat.subscribe(self.twitch_chat)

        print("Connected to Channel: ", channel_name)
Beispiel #10
0
    def __call__(self):
        # pass
        print("bot starting")
        print("Getting Token")
        # self.get_oauth()
        # webbrowser.open(f"https://id.twitch.tv/oauth2/authorize?response_type=code&client_id={self.client_id}&redirect_uri=http://localhost&scope={'%20'.join(self.scopes)}")
        # print(f"Please go to https://id.twitch.tv/oauth2/authorize?response_type=code&client_id={self.client_id}&redirect_uri=http://localhost&scope={'%20'.join(self.scopes)}")

        # self.server = threading.Thread(target=self.app.run, kwargs={'port':80}, daemon=True)
        # self.server.start()
        # self.code_available.wait()
        # self.server.join()
        print("Code Obtained")
        print(f"Code: {self.code}")
        self.helix = twitch.Helix(client_id=self.client_id,
                                  client_secret=self.client_secret,
                                  use_cache=True,
                                  bearer_token=self.token)  #, code=self.code)
        self.chat = twitch.Chat(channel=self.channel,
                                nickname=self.nickname,
                                oauth=self.oauth,
                                helix=self.helix)
        self.chat.subscribe(self.handle_message)
Beispiel #11
0
    def connect_to_chat(self, message_checker, verbose_connect=False):
        try:
            self.chat_connection = twitch.Chat(channel=self.channel,
                                               nickname=self.nickname,
                                               oauth=self.oauth)

            # call message_checker on every received message
            self.chat_connection.subscribe(
                lambda message: message_checker(message))
            # Log every message
            self.chat_connection.subscribe(
                lambda message: self.log_message(message))

            # Advertise connect in channel if set
            if (verbose_connect):
                self.send_message("I just connected...")

            self.logger.info("Connected to channel: " + self.channel)

            return self.chat_connection

        except Exception as e:
            self.logger.exception("Error connecting to channel: " +
                                  self.channel)
def track_channel(channel):
    """
    Track channel and add it to DB if channel exists on twitch
    and it does not exist on DB

    :param channel: channel_id
    :return: Boolean
    """

    if channel_exists(channel) and not Channel.get(channel_id=channel):
        # Add channel to DB
        Channel(channel_id=channel)
        commit()

        # Subscribe to chat
        twitch.Chat(channel=f"#{channel}", nickname=NICKNAME,
                    oauth=OAUTH).subscribe(log_message)

        return True

    print(
        "This channel does not exist on Twitch or was already subscribed to!")

    return False
Beispiel #13
0
obshost = config['obs-websockets']['host']
obsport = config['obs-websockets']['port']
obspass = str(config['obs-websockets']['password'])
obsinstance = obsws(obshost, obsport, obspass)
obsinstance.connect()
log.info("Connected to OBS!")

#* Twitch Chat Settings
if config['twitch']['enabled'] == "yes":
    twchannel = '#' + config['twitch']['channel']
    twnickname = config['twitch']['nickname']
    twoauth = config['twitch']['oauth']
    twclientid = config['twitch']['clientid']
    chat = twitch.Chat(channel=twchannel,
                       nickname=twnickname,
                       oauth=twoauth,
                       helix=twitch.Helix(client_id=twclientid,
                                          use_cache=True))
    log.info("Connected to Twitch Chat!")


def openfile():
    tempfile = []
    fileref = open("input.yml", 'r', encoding="utf-8")
    for data in yaml.safe_load_all(fileref):
        #print(data)
        tempfile.append(data)

    log.info(tempfile)
    log.info("Parsed YAML")
    return tempfile
Beispiel #14
0

    vibrato = args.vibrato
    rand_min = args.rand_min
    rand_max = args.rand_max
    coef = args.coef
    time_bip = args.time_bip


    _twitch = os.path.isfile('./.twitch')

    if not _twitch:
        print('twitch_params_error: not .twitch file found')

    with open('./.twitch') as json_file:
        twitch_params = json.load(json_file)

        # TWITCH

        helix = twitch.Helix(twitch_params[0], twitch_params[1])
        OAUTH_KEY = twitch_params[2] # https://twitchapps.com/tmi/
        pseudo = twitch_params[3]

        channel = input('channel: ')
        if channel:
            print("[Twitch] watcher for " + channel)
            chat = twitch.Chat(channel='#'+channel, nickname=pseudo[0], oauth=OAUTH_KEY)
            chat.subscribe(
                lambda message: gen_sound(message)
            )
 def __init__(self, streamer):
     self.streamer = streamer
     self.chat = twitch.Chat(channel=streamer.name, nickname=NICKNAME, oauth=OAUTH_TOKEN).subscribe(
         lambda message: self.process_message(message, streamer))
     print_debug("connected to {}".format(streamer.name))
Beispiel #16
0
 def monitor(self):
     print(f"Watching for messages in {self.channel}...")
     twitch.Chat(channel=self.channel, nickname="spliitzx", oauth=OAUTH).subscribe(lambda message: self.handle_message(message))
Beispiel #17
0
import twitch
import webbrowser
import time
import threading
import queue

h = twitch.Helix('rst4gol14h5s86eax89ju3ot6uipuy')

chat = twitch.Chat(channel='thebasementclub',
                   nickname='Banishment_of_this_World',
                   oauth='oauth:g62i86e9gtdc5fyj2suncmcxplqc6r')

chat.subscribe(
    lambda message: print(message.channel, message.sender, message.text))

# thread_chat_update = threading.Thread(target=client.process_forever)
# thread_chat_update.start()

# while True:
#     try:
#         messages = client.messages.get(False)
#         if messages.text == "!ping":
#             client.send_msg("pong!")
#     except queue.Empty:
#         pass

# print('done')
Beispiel #18
0
            player_data = json.load(f)
    else:
        f = open('players.json', 'w')  # create file if it doesn't exist
        f.close()
        player_data = {}

    room_id = tkinter.StringVar()
    room_pass = tkinter.StringVar()

    # room_id = input('Room ID: ')
    # room_pass = input('Password (optional): ')

    q = PlayerQueue(player_data)
    chat = twitch.Chat(channel='#' + CHANNEL,
                       nickname='PlayerQueueBot',
                       oauth=OAUTH,
                       helix=twitch.Helix(client_id=CLIENT_ID,
                                          client_secret=CLIENT_SECRET,
                                          use_cache=True))

    def handler(message):
        return handle_message(q, message)

    chat.subscribe(handler)

    # Configure button commands
    main_gui.next_player_button.config(command=lambda: next_player(
        q, chat, main_gui.current_player_label, room_id, room_pass))
    main_gui.top_players_button.config(
        command=lambda: show_top_players(q.get_top_players()))
    main_gui.exit_button.config(command=lambda: exit_program(q, chat))
    main_gui.m.protocol(
Beispiel #19
0
import twitch
import json
from datetime import datetime
# Username of your channel
username = '******'
# oauth to get on twitch.com
password = '******'
# channels to scrap
channels = 'domingo'
# Name to response 
to_answser = ''


chat_live = twitch.Chat(channel=channels, nickname=username, oauth=password)

def send_response(message):
    if message.sender == to_answser:
        chat_live.irc.send_message(message='Salut Theops', channel=chat_live.channel)

chat_live.subscribe(
            lambda message: send_response(message)
            )

Beispiel #20
0
def connect_to_chat(channel: str, nickname: str, oauth: str) -> twitch.Chat:
    l.info('connecting to {}'.format(channel))
    return twitch.Chat(channel=channel, nickname=nickname, oauth=oauth)
Beispiel #21
0
def main():
    chat = twitch.Chat(channel='#' + NICK,
                       nickname=NICK,
                       oauth=PASS,
                       helix=twitch.Helix(client_id=PASS, use_cache=True))
    chat.subscribe(handle_message)
load_dotenv()

CLIENT_ID = os.getenv("CLIENT_ID")
CLIENT_SECRET = os.getenv("CLIENT_SECRET")
OAUTH_TOKEN = os.getenv("OAUTH_TOKEN")

helix = twitch.Helix(CLIENT_ID, CLIENT_SECRET)
score = stream.Score()
numNotes = 1
composers = []

STREAMER_NAME = "ezra0110"

twitch.Chat(
    channel='#' + STREAMER_NAME, nickname=STREAMER_NAME,
    oauth=OAUTH_TOKEN).subscribe(lambda message: message_handler(message))


def message_handler(message):
    # global composers
    global score
    global composers
    message_text = message.text
    message_sender = message.sender
    print(message_sender, message_text)
    arr = message_text.split(',')
    lastNote = None
    # print(arr)
    try:
        if len(arr