Fix control user check

master
Nikola Forró 6 years ago
parent c0599c839d
commit 2bbc4c7dd5

@ -68,15 +68,15 @@ class ReplayBot(irc.bot.SingleServerIRCBot):
message = ''.join([c for c in event.arguments[0] if not unicodedata.category(c).startswith('C')])
message = message.rstrip()
send_response = functools.partial(self._send_response, connection, event)
if int(tags['user-id']) != self.control_user:
send_response('Sorry @{0}, you are not allowed to do this'.format(tags['display-name']))
return
for pattern, action in self.supported_commands:
m = pattern.match(message)
if m:
action(tags, send_response, **m.groupdict())
def _do_load(self, tags, send_response, id, **kwargs):
if int(tags['user-id']) != self.control_user:
send_response('Sorry @{0}, you are not allowed to do this'.format(tags['display-name']))
return
client_id = self.config['Twitch'].get('client_id')
def get_comments(cursor):
url = 'https://api.twitch.tv/v5/videos/{0}/comments'.format(id)
@ -103,6 +103,9 @@ class ReplayBot(irc.bot.SingleServerIRCBot):
send_response('@{0}: failed to load messages'.format(tags['display-name']))
def _do_start(self, tags, send_response, **kwargs):
if int(tags['user-id']) != self.control_user:
send_response('Sorry @{0}, you are not allowed to do this'.format(tags['display-name']))
return
now = datetime.datetime.utcnow().replace(tzinfo=datetime.timezone.utc)
for offset, user, msg in self.messages:
def cb(user=user, msg=msg):
@ -110,6 +113,9 @@ class ReplayBot(irc.bot.SingleServerIRCBot):
self.reactor.scheduler.execute_at(now + offset, cb)
def _do_stop(self, tags, send_response, **kwargs):
if int(tags['user-id']) != self.control_user:
send_response('Sorry @{0}, you are not allowed to do this'.format(tags['display-name']))
return
self.reactor.scheduler.queue.clear()
def _post_message(self, user, msg):

Loading…
Cancel
Save