Add !reload command for reloading extra commands

master
Nikola Forró 6 years ago
parent 1e8848ac98
commit be7187d3a7

@ -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 - `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 * `!syncquotes` - performs synchronization of the quotes database with Twitch VODs
- only master user is allowed to use this command - 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

@ -49,6 +49,7 @@ class TwitchClient(irc.bot.SingleServerIRCBot):
(re.compile(r'^!(bella(gram|pics)|insta(gram|bella))$'), self._do_bellagram), (re.compile(r'^!(bella(gram|pics)|insta(gram|bella))$'), self._do_bellagram),
(re.compile(r'^!yt\s+(?P<q>")?(?P<query>.+)(?(q)")$'), self._do_yt), (re.compile(r'^!yt\s+(?P<q>")?(?P<query>.+)(?(q)")$'), self._do_yt),
(re.compile(r'^!clip\s+(?P<q>")?(?P<filter>.+)(?(q)")$'), self._do_clip), (re.compile(r'^!clip\s+(?P<q>")?(?P<filter>.+)(?(q)")$'), self._do_clip),
(re.compile(r'^!reload$'), self._do_reload),
] ]
server = self.config['IRC'].get('server') server = self.config['IRC'].get('server')
port = self.config['IRC'].getint('port') 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)) send_response('Sorry @{0}, {1}'.format(tags['display-name'], e))
else: else:
send_response('{0}: {1}'.format(result['title'], result['url'])) 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')

Loading…
Cancel
Save