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'
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
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
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()