-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathLoremIpsum.py
More file actions
44 lines (37 loc) · 1.26 KB
/
LoremIpsum.py
File metadata and controls
44 lines (37 loc) · 1.26 KB
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
37
38
39
40
41
42
43
44
from .. import loader, utils
import io
from requests import get
def register(cb):
cb(LoremIpsumMod())
class LoremIpsumMod(loader.Module):
"""Lorem Ipsum generation"""
strings = {'name': 'LoermIpsum'}
def __init__(self):
self.name = self.strings['name']
async def loremipsumcmd(self, message):
""".loremipsum <count: int> <length: str> <file?>
count - number of paragraphs| std: 1
length - s-short, m-medium, l-long, v-verylong|std: m(edium)
file - if nothing- send as message, if anything- send as file"""
s = 'small'
m = length = 'medium'
l = 'long'
v = 'verylong'
args = utils.get_args(message)
count = 1
as_file = False
if args:
count = int(args[0]) if args[0].isdigit() else 1
if len(args) == 2:
lenght = args[1].lower()
length = s if lenght in [s[:i+1] for i in range(len(s))] else l if lenght in [l[:i+1] for i in range(len(l))] else v if lenght in [v[:i+1] for i in range(len(v))] else m # сижу ахуел
if len(args) >= 3:
as_file = True
url = f"https://loripsum.net/api/{count}/{length}/plaintext"
out = get(url)
if as_file:
out = io.BytesIO(out.content)
out.name = f"LoremIpsum.{count}.txt"
out.seek(0)
else: out = out.text
await utils.answer(message, out)