From 4438126fd7fe86744880723fd5014e9f9c4448f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Forr=C3=B3?= Date: Mon, 27 Aug 2018 16:06:49 +0200 Subject: [PATCH] Allow multiple control users --- rerunbot.py | 10 +++++----- settings.cfg.example | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/rerunbot.py b/rerunbot.py index 6fe10bb..e41407c 100644 --- a/rerunbot.py +++ b/rerunbot.py @@ -32,7 +32,7 @@ class ReplayBot(irc.bot.SingleServerIRCBot): self.output_channel = '#{0}'.format(self.config['IRC'].get('output_channel')) control_channel = self.config['IRC'].get('control_channel') self.control_channel = '#{0}'.format(control_channel) if control_channel else None - self.control_user = self.config['IRC'].getint('control_user') + self.control_users = self.config['IRC'].get('control_users').split(',') server = self.config['IRC'].get('server') port = self.config['IRC'].getint('port') nickname = self.config['IRC'].get('nickname') @@ -77,7 +77,7 @@ class ReplayBot(irc.bot.SingleServerIRCBot): action(tags, send_response, **m.groupdict()) def _do_load(self, tags, send_response, id, **kwargs): - if int(tags['user-id']) != self.control_user: + if tags['user-id'] not in self.control_users: send_response('Sorry @{0}, you are not allowed to do this'.format(tags['display-name'])) return client_id = self.config['Twitch'].get('client_id') @@ -106,7 +106,7 @@ class ReplayBot(irc.bot.SingleServerIRCBot): send_response('@{0}: failed to load messages'.format(tags['display-name'])) def _do_start(self, tags, send_response, at=None, **kwargs): - if int(tags['user-id']) != self.control_user: + if tags['user-id'] not in self.control_users: send_response('Sorry @{0}, you are not allowed to do this'.format(tags['display-name'])) return if at is None: @@ -119,7 +119,7 @@ class ReplayBot(irc.bot.SingleServerIRCBot): self.reactor.scheduler.execute_at(t + offset, cb) def _do_resync(self, tags, send_response, offset, **kwargs): - if int(tags['user-id']) != self.control_user: + if tags['user-id'] not in self.control_users: send_response('Sorry @{0}, you are not allowed to do this'.format(tags['display-name'])) return offset = datetime.timedelta(seconds=float(offset)) @@ -131,7 +131,7 @@ class ReplayBot(irc.bot.SingleServerIRCBot): self.reactor.scheduler.queue[i] = ndc def _do_stop(self, tags, send_response, **kwargs): - if int(tags['user-id']) != self.control_user: + if tags['user-id'] not in self.control_users: send_response('Sorry @{0}, you are not allowed to do this'.format(tags['display-name'])) return with self.reactor.mutex: diff --git a/settings.cfg.example b/settings.cfg.example index 24c629a..f8bdd6c 100644 --- a/settings.cfg.example +++ b/settings.cfg.example @@ -3,7 +3,7 @@ server = irc.chat.twitch.tv port = 6667 nickname = __BOT_NICKNAME__ output_channel = __OUTPUT_CHANNEL__ -control_user = __CONTROL_USER_ID__ +control_users = __CONTROL_USER_ID__,... control_channel = __CONTROL_CHANNEL__ [Twitch]