remove '@' in mention link while manually @someone

This commit is contained in:
Rongrong 2021-08-06 23:46:51 +08:00 committed by GitHub
parent 15b83dc637
commit ecf74e3bff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -21,7 +21,7 @@ else:
# Find someone's full name by their username
def find_name_by_username(username: str) -> str:
r = requests.get(f'https://t.me/{username.replace("@", "")}')
r = requests.get(f'https://t.me/{username}')
return re.search('(?<=<meta property="og:title" content=").*(?=")', r.text, re.IGNORECASE).group(0)
@ -55,7 +55,7 @@ def get_users(msg):
offset = mentions[0]['offset']
length = mentions[0]['length']
text = msg['text']
username = text[offset : offset + length]
username = text[offset : offset + length].replace("@", "")
rpl_user = {'first_name': find_name_by_username(username), 'username': username}
# Remove mention from message text