add mention checker to utils
This commit is contained in:
parent
b32a704e12
commit
ec25b73c4f
2 changed files with 8 additions and 1 deletions
4
bot.py
4
bot.py
|
|
@ -10,6 +10,8 @@ from pyzxz.pyzxz.pyzxz import ZeroXZero # :sob:
|
|||
from lastfmcollagegenerator.collage_generator import CollageGenerator
|
||||
# from catbox_async_uploader.catbox_async_uploader.core import CatboxAsyncUploader
|
||||
|
||||
import utils as u
|
||||
|
||||
class Bot(nerimity.Client):
|
||||
"""Extended client class for extra functionality."""
|
||||
def __init__(self, lastfm_api_key: str, lastfm_api_secret: str,
|
||||
|
|
@ -101,7 +103,7 @@ class Bot(nerimity.Client):
|
|||
if not username:
|
||||
await ctx.send(u.error_msg("Please provide a Last.fm username (or set yours with `/setfm`)."))
|
||||
|
||||
elif username.startswith("[@:"):
|
||||
elif u.is_mention(username):
|
||||
mentioned = self.get_user(username[3:-1])
|
||||
try: username = await self.get_lastfm(mentioned.id)
|
||||
except Exception as e:
|
||||
|
|
|
|||
5
utils.py
5
utils.py
|
|
@ -37,3 +37,8 @@ def error_msg(message: str) -> str:
|
|||
|
||||
def good_msg(message: str) -> str:
|
||||
return f"[#52ff54][Success] [#reset]{message}"
|
||||
|
||||
def is_mention(mention: str) -> bool:
|
||||
if not mention: return None
|
||||
|
||||
return True if mention.startswith("[@:") else False
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue