From 89562618a857a53ea8fb880ba966c6e028a200f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Forr=C3=B3?= Date: Wed, 29 Aug 2018 18:26:32 +0200 Subject: [PATCH] Implement user blacklist and message template --- rerunbot.py | 6 +++++- settings.cfg.example | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/rerunbot.py b/rerunbot.py index acfca0c..f799a37 100644 --- a/rerunbot.py +++ b/rerunbot.py @@ -81,6 +81,7 @@ class ReplayBot(irc.bot.SingleServerIRCBot): send_response('Sorry @{0}, you are not allowed to do this'.format(tags['display-name'])) return client_id = self.config['Twitch'].get('client_id') + user_blacklist = self.config['Rerun'].get('user_blacklist').split(',') def get_comments(cursor): url = 'https://api.twitch.tv/v5/videos/{0}/comments'.format(id) params = dict(client_id=client_id, cursor=cursor) @@ -92,6 +93,8 @@ class ReplayBot(irc.bot.SingleServerIRCBot): while True: data = get_comments(cursor) for comment in data.get('comments', []): + if comment['commenter']['_id'] in user_blacklist: + continue self.messages.append(( datetime.timedelta(seconds=float(comment['content_offset_seconds'])), comment['commenter']['display_name'], @@ -149,7 +152,8 @@ class ReplayBot(irc.bot.SingleServerIRCBot): self.reactor.scheduler.queue.clear() def _post_message(self, user, msg): - self.connection.privmsg(self.output_channel, '[{0}]: {1}'.format(user, msg)) + text = self.config['Rerun'].get('message_template').format(username=user, message=msg) + self.connection.privmsg(self.output_channel, text) def main(): diff --git a/settings.cfg.example b/settings.cfg.example index f8bdd6c..a9ee92d 100644 --- a/settings.cfg.example +++ b/settings.cfg.example @@ -9,3 +9,7 @@ control_channel = __CONTROL_CHANNEL__ [Twitch] token = oauth:__TWITCH_OAUTH_TOKEN__ client_id = __TWITCH_CLIENT_ID__ + +[Rerun] +user_blacklist = __BLACKLISTED_USER_ID__,... +message_template = [{username}]: {message}