From 7ff5c8b0f755bcb24c9c1aaa0198c59303c05739 Mon Sep 17 00:00:00 2001 From: CMDR furrycat Date: Tue, 6 Dec 2016 08:24:27 +0000 Subject: [PATCH] Added format_mention(). --- bot.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/bot.py b/bot.py index 749e3bc..7998e3e 100644 --- a/bot.py +++ b/bot.py @@ -252,6 +252,13 @@ def parse_mention(text, author): log.warning("Can't parse {}!".format(text)) return None +def format_mention(mention): + if mention in ['everyone', 'here']: + return '@{}'.format(mention) + if mention[0] == '#': + return '<{}>'.format(mention) + return '<@{}>'.format(mention) + def open_url(url): # Specify our own user agent as Cloudflare doesn't seem to like the urllib one try: -- 2.7.4