Пример #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)
Пример #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()
Пример #3
0
#!/usr/bin/env python

from time import sleep
import sys
import json
import re

from youtubechat import YoutubeLiveChat, get_live_chat_id_for_broadcast_id, get_live_chat_id_for_stream_now

getStringWithDecodedUnicode = lambda str: re.sub('\\\\u([\da-f]{4})', (
    lambda x: chr(int(x.group(1), 16))), str)

#Input FilePath of "oauth_creds", "broadcastid"
FILE_PATH = 'D:/@University/team-12-final/'

f = open(FILE_PATH + "broadcastid", "r")

broadcast_id = f.read()
print(broadcast_id)

livechat_id = get_live_chat_id_for_broadcast_id(broadcast_id,
                                                FILE_PATH + "oauth_creds")
print(livechat_id)

chat_obj = YoutubeLiveChat(FILE_PATH + "oauth_creds", [livechat_id])
f = open(FILE_PATH + "chatdata.json", "w")

dataaa = chat_obj.livechat_api.get_all_messages(livechat_id)
dataaa = json.dumps(dataaa)
f.write(dataaa)
f.close()