Implement user blacklist and message template

master
Nikola Forró 6 years ago
parent 4b50d70dbe
commit 89562618a8

@ -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():

@ -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}

Loading…
Cancel
Save