-
Notifications
You must be signed in to change notification settings - Fork 33
/
square.py
36 lines (34 loc) · 1.14 KB
/
square.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from pagermaid.listener import listener
from pagermaid.utils import alias_command
from pagermaid import version
@listener(is_plugin=True, outgoing=True, command=alias_command("square"),
description="生成文本矩形",
parameters="<文本> <行> <列>")
async def square(context):
if not len(context.parameter) > 2:
await context.edit('出错了呜呜呜 ~ 参数错误。')
return
parameters = context.parameter[-2:]
hang = parameters[0]
lie = parameters[1]
try:
hang = int(hang)
lie = int(lie)
except ValueError:
await context.edit('出错了呜呜呜 ~ 参数错误。')
return
if hang < 1 or lie < 1:
await context.edit('出错了呜呜呜 ~ 参数错误。')
return
parameters = [i for i in context.parameter if i not in parameters]
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)