From: CMDR furrycat Date: Sat, 5 Nov 2016 10:07:53 +0000 (+0000) Subject: Greeting fixes. X-Git-Url: http://git.furryclan.net/?a=commitdiff_plain;h=c3961f84e1bcc2f6e28443cc06e60d443af672a7;p=furrycat%2Fcatbot.git Greeting fixes. --- diff --git a/plugin/greetings/greetings.py b/plugin/greetings/greetings.py index 33efc90..fc28a9d 100644 --- a/plugin/greetings/greetings.py +++ b/plugin/greetings/greetings.py @@ -236,23 +236,26 @@ class Greetings(DBConnection): if editing and arg == 'voice' and param == 'none': parsed[k] = None ok = True + elif param == 'here': + if arg != 'in': + break + if message.channel.is_private: + log.warning("Can't greet in private channel.") + break + else: + parsed[k] = message.channel.id + ok = True + elif param == 'private': + log.warning("Can't greet in private channel.") + break elif param: - m = re.match(r'<#(\d+)>', param) - if m is None: - m = re.match(r'#(\d+)', param) - if m is not None: - parsed[k] = m.group(1) + args = {} + if arg == 'in': + args['voice_ok'] = False + channel = bot.parse_channel(param, **args) + if channel is not None: + parsed[k] = channel.id ok = True - else: - m = re.match(r'#(.+)', param) - if m is None: - break - # Look for a channel with that name. - for channel in client.get_all_channels(): - if channel.name == m.group(1): - parsed[k] = channel.id - ok = True - break elif arg == 'sound': k = arg if editing and param == 'none': @@ -326,7 +329,7 @@ class Greetings(DBConnection): create['id'] = id log.info('Created greeting: {}'.format(create)) yield from bot.say(message.channel, id) - yield from cat.purr(None, voice_channel_for_user(message.author), join = False) + yield from cat.purr(None, bot.voice_channel_for_user(message.author), join = False) else: log.info('Failed to create greeting: {}'.format(create)) yield from cat.yelp(message.channel) @@ -350,7 +353,7 @@ class Greetings(DBConnection): if self.update_greeting(client, id, **update): log.info('Edited greeting {}: {}'.format(id, update)) yield from bot.say(message.channel, ', '.join([self.greeting_key(k) for k in update])) - yield from cat.purr(None, voice_channel_for_user(message.author), join = False) + yield from cat.purr(None, bot.voice_channel_for_user(message.author), join = False) else: log.info('Failed to edit greeting {}: {}'.format(id, update)) yield from cat.yelp(message.channel)