Esempio n. 1
0
 def __init__(self, config):
     self.config = config
     self.tirc = twitch_chat(config['twitch_username'],
                             config['twitch_oauth'],
                             [config['twitch_channel']],
                             config['client_id'])
     self.tirc.subscribeChatMessage(self.new_twitchmessage)
     self.chatId = get_live_chat_id_for_stream_now('oauth_creds')
     self.ytchat = YoutubeLiveChat('oauth_creds', [self.chatId])
     self.ytchat.subscribe_chat_message(self.new_ytmessage)
Esempio n. 2
0
#!/usr/bin/env python

from time import sleep

from youtubechat import YoutubeLiveChat, get_live_chat_id_for_stream_now

livechat_id = get_live_chat_id_for_stream_now("oauth_creds")
chat_obj = YoutubeLiveChat("oauth_creds", [livechat_id])


# msg in this case is a LiveChatMessage object defined in ytchat.py
def respond(msgs, chatid):
    for msg in msgs:
        print(f"NEW MESSAGE: {msg.published_at} | {msg}")
        #print(msg)
        #msg.delete()
        #chat_obj.send_message("RESPONSE!", chatid)


try:
    chat_obj.start()
    chat_obj.subscribe_chat_message(respond)
    chat_obj.join()

finally:
    chat_obj.stop()
Esempio n. 3
0
 thandler.subscribe_viewers_change(console.new_viewers)
 console.display_message("Loading twitch_message handler")
 tirc = twitch_chat(config['twitch_username'], config['twitch_oauth'], config['twitch_channels'],
                    config['client_id'])
 tirc.subscribeChatMessage(console.new_twitchmessage)
 tirc.subscribeNewSubscriber(console.new_subscriber)
 ytchat = None
 if 'youtube_enabled' in config:
     if config['youtube_enabled']:
         console.display_message("Grabbing youtube chat id")
         chatId = None
         if args.testyoutube:
             from youtubechat import get_top_stream_chat_ids
             chatId = get_top_stream_chat_ids("oauth_creds")[0]
         else:
             chatId = get_live_chat_id_for_stream_now('oauth_creds')
         console.display_message("Loading youtube chat handler")
         ytchat = YoutubeLiveChat('oauth_creds', [chatId])
         ytchat.subscribe_chat_message(console.new_ytmessage)
 if 'ignored_users' in config:
     for user in config['ignored_users']:
         console.ignore_user(user)
 try:
     console.display_message("Loading complete, awaiting messages")
     console.start()
     thandler.start()
     tirc.start()
     if ytchat:
         ytchat.start()
     while True:
         time.sleep(0.1)
Esempio n. 4
0
#!/usr/bin/env python

from time import sleep

from youtubechat import YoutubeLiveChat, get_live_chat_id_for_stream_now

livechat_id = get_live_chat_id_for_stream_now("oauth_creds")
chat_obj = YoutubeLiveChat("oauth_creds", [livechat_id])


def respond(msgs, chatid):
    for msg in msgs:
        print(msg)
        msg.delete()
        chat_obj.send_message("RESPONSE!", chatid)


try:
    chat_obj.start()
    chat_obj.subscribe_chat_message(respond)
    chat_obj.join()

finally:
    chat_obj.stop()