3434 chat_is_allowed ,
3535 clean_reply ,
3636 get_args ,
37+ get_mention ,
3738 get_msg_from_codes ,
39+ get_user_info ,
40+ is_mention ,
3841 sanitize_text ,
3942 user_is_allowed ,
4043 user_is_privileged ,
@@ -48,7 +51,7 @@ async def enka_handler(event, args, client):
4851 Requires character build for the specified uid to be public
4952
5053 Arguments:
51- uid: {genshin player uid} (Required)
54+ uid/@mention : {genshin player uid} (Required)
5255 -c or --card or --character {character name}*: use quotes if the name has spaces eg:- "Hu tao"; Also supports lookups
5356 -cs or --cards or --characters {characters} same as -c but for multiple characters; delimited by commas
5457 -t <int> {template}: card generation template; currently only two templates exist; default 1
@@ -80,7 +83,7 @@ async def enka_handler(event, args, client):
8083 if not chat_is_allowed (event ):
8184 return
8285 if not user_is_allowed (user ):
83- return await event . react ( "⛔" )
86+ return
8487 try :
8588 arg , unknown = get_args (
8689 ["--hide_uid" , "store_true" ],
@@ -111,11 +114,18 @@ async def enka_handler(event, args, client):
111114 )
112115 unknowns = unknown .split ()
113116 invalid = str ()
117+ mention = None
118+ mentioned_id = None
119+ r_mention = None
114120 uid = None
115121 for unkwn in unknowns :
116122 if unkwn .isdigit () and not uid :
117123 uid = unkwn
118124 continue
125+ elif (unkwn .startswith ("@" ) or (unkwn .startswith ("[@" ) and is_mention (unkwn ))) and not mention :
126+ mention = get_mention (unkwn )
127+ r_mention = unkwn
128+ continue
119129 invalid += f"{ unkwn } "
120130 invalid = invalid .rstrip ()
121131 card = arg .c or arg .card or arg .character
@@ -135,6 +145,14 @@ async def enka_handler(event, args, client):
135145 if not vital_args :
136146 return await u_reply .edit ("Updated enka assets." )
137147 await u_reply .delete ()
148+ if mention and uid :
149+ await event .reply ("`Ignoring your mention…`" )
150+ elif mention :
151+ mentioned = await get_user_info (mention )
152+ not_found_err = "**No idea who {} is.**"
153+ if not mentioned :
154+ return await event .reply (not_found_err .format (r_mention ))
155+ mentioned_id = mentioned .id
138156 if uid and save :
139157 will_save = True
140158 if bot .user_dict .get (user , {}).get ("genshin_uid" ) == uid :
@@ -151,7 +169,7 @@ async def enka_handler(event, args, client):
151169 if not vital_args :
152170 return
153171 if not uid :
154- uid = bot .user_dict .get (user , {}).get ("genshin_uid" , None )
172+ uid = bot .user_dict .get (( mentioned_id or user ) , {}).get ("genshin_uid" , None )
155173 if delete :
156174 if not (saved_uid := bot .user_dict .get (user , {}).get ("genshin_uid" )):
157175 await event .reply ("**No saved uid was found to delete!**" )
@@ -166,7 +184,11 @@ async def enka_handler(event, args, client):
166184 if not uid :
167185 if invalid :
168186 await event .reply (f"`{ invalid } `?" )
169- return await event .reply (f"**Please supply a UID**" )
187+ if mention :
188+ err_msg = f"**Error:** { mentioned .mention ()} hasn't saved their uid!"
189+ else :
190+ err_msg = "**Please supply a UID**"
191+ return await event .reply (err_msg )
170192 if invalid :
171193 await event .reply (f"**Warning:** No idea what '`{ invalid } `' means." )
172194 if arg .t not in ("1" , "2" ):
@@ -180,7 +202,10 @@ async def enka_handler(event, args, client):
180202 await event .reply (characters )
181203 if not (card or cards or dump or prof ):
182204 return
183- status = await event .reply ("`Fetching card(s), Please Wait…`" )
205+ status_msg = "`Fetching card(s)"
206+ status_msg += f" for { mentioned .first_name } " if mention else str ()
207+ status_msg += ", Please Wait…`"
208+ status = await event .reply (status_msg )
184209 if prof :
185210 cprofile , error = (
186211 await get_enka_profile (uid , card = True , template = arg .t , huid = hide_uid )
0 commit comments