From: CMDR furrycat Date: Tue, 6 Dec 2016 10:19:53 +0000 (+0000) Subject: Use mention methods. X-Git-Url: http://git.furryclan.net/?a=commitdiff_plain;h=891380eb029a602359e87a070eb38fb57fa58128;p=furrycat%2Fcatbot.git Use mention methods. --- diff --git a/plugin/announcements/announcements.py b/plugin/announcements/announcements.py index 1191248..173f2f1 100644 --- a/plugin/announcements/announcements.py +++ b/plugin/announcements/announcements.py @@ -384,14 +384,11 @@ class Announcements(DBConnection): text += ' every {}'.format(bot.unparse_seconds(int(announcement.interval))) mention = announcement.mention if mention: - if mention == 'everyone' or mention == 'here': + if message.channel.is_private and mention[0] == '&': + # Can't mention a role in a private channel. text += ' tell @{}'.format(mention) else: - if message.channel.is_private and mention[0] == '&': - # Can't mention a role in a private channel. - text += ' tell @{}'.format(mention) - else: - text += ' tell <@{}>'.format(mention) + text += ' tell {}'.format(bot.format_mention(mention)) if announcement.channel_id != announcement.voice_id: if announcement.is_private: text += ' in private' @@ -512,19 +509,10 @@ class Announcements(DBConnection): if editing and param == 'none': parsed['mention'] = None ok = True - elif param == 'me': - parsed['mention'] = message.author.id - if 'channel_id' not in parsed: - parsed['channel_id'] = 'private' - ok = True elif param: - m = re.match(r'<@((?:&?|#)\d+)>', param) - if m is None: - m = re.match(r'@((?:&?|#)\d+)', param) - if m is None: - m = re.match('r@(everyone|here)', param) - if m is not None: - parsed['mention'] = m.group(1) + mention = bot.parse_mention(param, message.author) + if mention: + parsed['mention'] = mention ok = True else: break @@ -830,10 +818,7 @@ class Announcements(DBConnection): text = announcement.message mention = announcement.mention if mention: - if mention in ['everyone', 'here']: - text = '@{}\n{}'.format(mention, text) - else: - text = '<@{}>\n{}'.format(mention, text) + text = '{}\n{}'.format(bot.format_mention(mention), text) digest = announcement.digest diff --git a/plugin/feeds/feeds.py b/plugin/feeds/feeds.py index 0b34ec6..db70248 100644 --- a/plugin/feeds/feeds.py +++ b/plugin/feeds/feeds.py @@ -180,12 +180,7 @@ class Feeds(DBConnection): continue formatted += '**{}**{}'.format(entry['title'], '\n{}'.format(link) if feed['show_link'] else '') if feed['mention']: - if feed['mention'] in ['everyone', 'here']: - formatted += '\n@{}'.format(feed['mention']) - elif feed['mention'][0] == '#': - formatted += '\n<{}>'.format(feed['mention']) - else: - formatted += '\n<@{}>'.format(feed['mention']) + formatted += '{}\n'.format(bot.format_mention(feed['mention'])) if feed['summary']: formatted += '\n{}'.format(''.join(bs4.BeautifulSoup(entry['summary'], 'html.parser').findAll(text = True))) formatted = formatted.strip()