Added first working chat recorder
This commit is contained in:
@@ -1,19 +1,17 @@
|
||||
import twitch
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class TwitchChatRecorder:
|
||||
def __init__(self, authenticator, streamer_name, on_finish=None):
|
||||
def __init__(self, api, streamer_name, ignored_prefix=["!"], on_finish=None):
|
||||
self.ignored_prefix = ignored_prefix
|
||||
self.on_finish = on_finish
|
||||
self.streamer_name = streamer_name
|
||||
self.authenticator = authenticator
|
||||
self.api = api
|
||||
|
||||
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)
|
||||
self.api.start_chat(self.streamer_name)
|
||||
|
||||
def on_error(self, error):
|
||||
logger.error(error)
|
||||
|
||||
Reference in New Issue
Block a user