2021-07-31 13:06:12 +00:00
|
|
|
from pagermaid.listener import listener
|
|
|
|
from pagermaid.utils import alias_command
|
2022-01-18 08:47:20 +00:00
|
|
|
from pagermaid import version
|
|
|
|
|
2021-07-31 13:06:12 +00:00
|
|
|
|
|
|
|
@listener(is_plugin=True, outgoing=True, command=alias_command("square"),
|
|
|
|
description="生成文本矩形",
|
2021-07-31 13:21:03 +00:00
|
|
|
parameters="<文本> <行> <列>")
|
2021-07-31 13:06:12 +00:00
|
|
|
async def square(context):
|
2021-07-31 13:21:03 +00:00
|
|
|
if not len(context.parameter) > 2:
|
2021-07-31 13:06:12 +00:00
|
|
|
await context.edit('出错了呜呜呜 ~ 参数错误。')
|
|
|
|
return
|
2021-07-31 13:21:03 +00:00
|
|
|
parameters = context.parameter[-2:]
|
|
|
|
hang = parameters[0]
|
|
|
|
lie = parameters[1]
|
2021-07-31 13:06:12 +00:00
|
|
|
try:
|
|
|
|
hang = int(hang)
|
|
|
|
lie = int(lie)
|
|
|
|
except ValueError:
|
|
|
|
await context.edit('出错了呜呜呜 ~ 参数错误。')
|
|
|
|
return
|
|
|
|
if hang < 1 or lie < 1:
|
|
|
|
await context.edit('出错了呜呜呜 ~ 参数错误。')
|
|
|
|
return
|
2021-07-31 13:21:03 +00:00
|
|
|
parameters = [i for i in context.parameter if i not in parameters]
|
2021-07-31 13:06:12 +00:00
|
|
|
text = " ".join(parameters)
|
|
|
|
text *= lie
|
|
|
|
text = text.strip()
|
|
|
|
result = []
|
|
|
|
for i in range(hang):
|
|
|
|
result.append(text)
|
|
|
|
result = '\n'.join(result)
|
|
|
|
if len(result) > 4096:
|
|
|
|
await context.edit('出错了呜呜呜 ~ 文本过长。')
|
|
|
|
else:
|
|
|
|
await context.edit(result)
|