From be7187d3a702f90062aafc3b68153f862f2cc44e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Forr=C3=B3?= Date: Thu, 26 Jul 2018 16:59:18 +0200 Subject: [PATCH] Add !reload command for reloading extra commands --- README.md | 2 ++ clients/twitch.py | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/README.md b/README.md index 8c679d5..b030cba 100644 --- a/README.md +++ b/README.md @@ -15,3 +15,5 @@ using [HTTP API](https://gitea.brno.mraveniste.cc/turbotraktor/ladylilia.com/src - `PATTERN` has to be at least 3 characters long and it can be enclosed in double quotes in case it contains spaces * `!syncquotes` - performs synchronization of the quotes database with Twitch VODs - only master user is allowed to use this command +* `!reload` - reloads the list of extra commands from the config file + - only master user is allowed to use this command diff --git a/clients/twitch.py b/clients/twitch.py index eba7b44..7f12fae 100644 --- a/clients/twitch.py +++ b/clients/twitch.py @@ -49,6 +49,7 @@ class TwitchClient(irc.bot.SingleServerIRCBot): (re.compile(r'^!(bella(gram|pics)|insta(gram|bella))$'), self._do_bellagram), (re.compile(r'^!yt\s+(?P")?(?P.+)(?(q)")$'), self._do_yt), (re.compile(r'^!clip\s+(?P")?(?P.+)(?(q)")$'), self._do_clip), + (re.compile(r'^!reload$'), self._do_reload), ] server = self.config['IRC'].get('server') port = self.config['IRC'].getint('port') @@ -186,3 +187,11 @@ class TwitchClient(irc.bot.SingleServerIRCBot): send_response('Sorry @{0}, {1}'.format(tags['display-name'], e)) else: send_response('{0}: {1}'.format(result['title'], result['url'])) + + def _do_reload(self, tags, send_response, **kwargs): + master_user_id = self.config['Twitch'].getint('master_user_id') + if int(tags['user-id']) != master_user_id: + respond('Sorry @{0}, you are not allowed to do this'.format(tags['display-name'])) + return + self.config.remove_section('Extra Commands') + self.config.read('settings.cfg')