teletype fix a bug

This commit is contained in:
xtaodada 2022-08-21 14:53:58 +08:00
parent 217d37396c
commit cebaeff68d
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659

View File

@ -1,25 +1,26 @@
from asyncio import sleep
from pyrogram import Client
from pagermaid.listener import listener
from pagermaid.utils import lang, Message
@listener(is_plugin=False, incoming=True, command="teletype",
description=lang('teletype_des'),
parameters="<message>")
async def teletype(_: Client, context: Message):
if not context.arguments:
return await context.edit("出错了呜呜呜 ~ 空白的参数。")
@listener(is_plugin=False, command="teletype",
description=lang('teletype_des'),
parameters="<message>")
async def teletype(message: Message):
if not message.arguments:
return await message.edit("出错了呜呜呜 ~ 空白的参数。")
try:
message = context.arguments
text = message.arguments
except ValueError:
await context.edit("出错了呜呜呜 ~ 无效的参数。")
await message.edit("出错了呜呜呜 ~ 无效的参数。")
return
interval = 0.05
cursor = ""
buffer = ''
msg = await context.edit(cursor)
msg = await message.edit(cursor)
await sleep(interval)
for character in message:
for character in text:
buffer = f"{buffer}{character}"
buffer_commit = f"{buffer}{cursor}"
await msg.edit(buffer_commit)
@ -28,4 +29,6 @@ async def teletype(_: Client, context: Message):
await msg.edit(buffer)
except MessageNotModifiedError:
pass
except Exception:
return
await sleep(interval)