Added skeleton for chat and video.

This commit is contained in:
Vitalii Lebedynskyi
2022-08-08 14:24:06 +03:00
parent a84e8abc14
commit e00fb5bd70
5 changed files with 85 additions and 29 deletions

22
clipper/chat.py Normal file
View File

@@ -0,0 +1,22 @@
import twitch
import logging
logger = logging.getLogger(__name__)
class TwitchChatRecorder:
def __init__(self, authenticator, streamer_name, on_finish=None):
self.on_finish = on_finish
self.streamer_name = streamer_name
self.authenticator = authenticator
def run(self):
chat = twitch.Chat(self.streamer_name, self.authenticator.username, self.authenticator.get_token())
logger.info("Subscribing to chat for %s as %s", self.streamer_name, self.authenticator.username)
chat.subscribe(on_next=self.on_message, on_error=self.on_error)
def on_error(self, error):
logger.error(error)
def on_message(self, msg):
logger.info("New message %s", msg)