🐛 sticker Not completely fix decode error

🐛 sticker 不完全修复极端条件下的贴纸名生成错误
This commit is contained in:
Xtao_dada 2021-04-14 00:43:23 +08:00 committed by GitHub
parent dffa87dee1
commit 17bf5b2d90
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -105,8 +105,15 @@ async def sticker(context):
pack_title += " (animated)"
command = '/newanimated'
response = request.urlopen(
request.Request(f'http://t.me/addstickers/{pack_name}'), context=ssl.create_default_context(cafile=certifi.where()))
try:
response = request.urlopen(
request.Request(f'http://t.me/addstickers/{pack_name}'), context=ssl.create_default_context(cafile=certifi.where()))
except UnicodeEncodeError:
pack_name = 's' + hex(context.sender.id)[2:]
if animated:
pack_name = 's' + hex(context.sender.id)[2:] + '_animated'
response = request.urlopen(
request.Request(f'http://t.me/addstickers/{pack_name}'), context=ssl.create_default_context(cafile=certifi.where()))
if not response.status == 200:
try:
await context.edit(lang('sticker_telegram_server_error'))