🔭 修复 sticker 包满无法切换的问题、防止等待时重复编辑消息、延长添加完毕删除消息的时间。

This commit is contained in:
Xtao_dada 2020-07-25 11:06:54 +08:00 committed by GitHub
parent 9694a7e275
commit 7c54103055
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -62,6 +62,7 @@ async def sticker(context):
if not custom_emoji: if not custom_emoji:
emoji = "👀" emoji = "👀"
pack = 1 pack = 1
sticker_already = False
if len(split_strings) == 3: if len(split_strings) == 3:
pack = split_strings[2] pack = split_strings[2]
emoji = split_strings[1] emoji = split_strings[1]
@ -101,7 +102,7 @@ async def sticker(context):
await conversation.send_message(pack_name) await conversation.send_message(pack_name)
chat_response = await conversation.get_response() chat_response = await conversation.get_response()
while chat_response.text == "Whoa! That's probably enough stickers for one pack, give it a break. \ while chat_response.text == "Whoa! That's probably enough stickers for one pack, give it a break. \
A pack can't have more than 120 stickers at the moment.": A pack can't have more than 120 stickers at the moment.":
pack += 1 pack += 1
pack_name = f"{user.username}_{pack}" pack_name = f"{user.username}_{pack}"
pack_title = f"@{user.username} 的私藏 ({pack})" pack_title = f"@{user.username} 的私藏 ({pack})"
@ -126,10 +127,12 @@ async def sticker(context):
await bot.send_read_acknowledge(conversation.chat_id) await bot.send_read_acknowledge(conversation.chat_id)
break break
except AlreadyInConversationError: except AlreadyInConversationError:
await context.edit("另一个命令正在添加贴纸, 等待中") if not sticker_already:
await sleep(0.5) await context.edit("另一个命令正在添加贴纸, 重新尝试中")
await context.edit("另一个命令正在添加贴纸, 重试中") sticker_already = True
pass else:
pass
sleep(.5)
except Exception: except Exception:
raise raise
else: else:
@ -141,7 +144,7 @@ async def sticker(context):
notification = await context.edit( notification = await context.edit(
f"这张图片/贴纸已经被添加到 [这个](t.me/addstickers/{pack_name}) 贴纸包。", f"这张图片/贴纸已经被添加到 [这个](t.me/addstickers/{pack_name}) 贴纸包。",
parse_mode='md') parse_mode='md')
await sleep(3) await sleep(5)
try: try:
await notification.delete() await notification.delete()
except: except: