square 修复空格被吞问题

This commit is contained in:
Xtao_dada 2021-07-31 21:21:03 +08:00 committed by GitHub
parent 3304b60d1c
commit 485c2d6444
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,13 +3,14 @@ from pagermaid.utils import alias_command
@listener(is_plugin=True, outgoing=True, command=alias_command("square"), @listener(is_plugin=True, outgoing=True, command=alias_command("square"),
description="生成文本矩形", description="生成文本矩形",
parameters="<行> <列> <文本>") parameters="<文本> <行> <列>")
async def square(context): async def square(context):
if not len(context.parameter): if not len(context.parameter) > 2:
await context.edit('出错了呜呜呜 ~ 参数错误。') await context.edit('出错了呜呜呜 ~ 参数错误。')
return return
hang = context.parameter[0] parameters = context.parameter[-2:]
lie = context.parameter[1] hang = parameters[0]
lie = parameters[1]
try: try:
hang = int(hang) hang = int(hang)
lie = int(lie) lie = int(lie)
@ -19,9 +20,7 @@ async def square(context):
if hang < 1 or lie < 1: if hang < 1 or lie < 1:
await context.edit('出错了呜呜呜 ~ 参数错误。') await context.edit('出错了呜呜呜 ~ 参数错误。')
return return
parameters = context.parameter parameters = [i for i in context.parameter if i not in parameters]
del parameters[0]
del parameters[0]
text = " ".join(parameters) text = " ".join(parameters)
text *= lie text *= lie
text = text.strip() text = text.strip()