Добавлена функция для удаления иконки подписок
This commit is contained in:
16
app/utils.py
16
app/utils.py
@@ -12,7 +12,7 @@ async def get_telegram_id(username: str) -> int:
|
||||
return telegram_user.id
|
||||
|
||||
|
||||
async def get_player_data(message: Message, idx: int) -> tuple():
|
||||
async def get_telegram_data(message: Message, idx: int) -> tuple():
|
||||
"""..."""
|
||||
if message.entities[idx].type == MessageEntityType.TEXT_LINK:
|
||||
player_url = message.entities[idx].url
|
||||
@@ -25,3 +25,17 @@ async def get_player_data(message: Message, idx: int) -> tuple():
|
||||
player_telegram_id = None
|
||||
|
||||
return (player_url, player_telegram_id)
|
||||
|
||||
|
||||
def clean_icons(text: str) -> str:
|
||||
"""Удаляет иконки подписок из ников"""
|
||||
|
||||
# оставляет ники игроков, Python не может в эмодзи в RegExp, по этому пришлось делать через str.replace()
|
||||
# player = re.sub(r'\s[⚡⚜]$', '', player)
|
||||
|
||||
output = text
|
||||
|
||||
for icon in ['⚡', '⚜', '💎']:
|
||||
output = output.replace(f' {icon}', '')
|
||||
|
||||
return output
|
||||
|
||||
Reference in New Issue
Block a user