-
Notifications
You must be signed in to change notification settings - Fork 0
/
QuoteGen.py
66 lines (53 loc) · 2.53 KB
/
QuoteGen.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
__version__ = (1, 0, 2)
# *
# * $$\ $$\ $$\ $$\ $$\
# * $$ | \__| $$ | $$ | $$ |
# * $$$$$$$\ $$$$$$$\ $$\ $$$$$$\ $$$$$$\$$$$\ $$$$$$\ $$$$$$$ |$$\ $$\ $$ | $$$$$$\ $$$$$$$\
# * $$ _____|$$ __$$\ $$ |\_$$ _| $$ _$$ _$$\ $$ __$$\ $$ __$$ |$$ | $$ |$$ |$$ __$$\ $$ _____|
# * \$$$$$$\ $$ | $$ |$$ | $$ | $$ / $$ / $$ |$$ / $$ |$$ / $$ |$$ | $$ |$$ |$$$$$$$$ |\$$$$$$\
# * \____$$\ $$ | $$ |$$ | $$ |$$\ $$ | $$ | $$ |$$ | $$ |$$ | $$ |$$ | $$ |$$ |$$ ____| \____$$\
# * $$$$$$$ |$$ | $$ |$$ | \$$$$ |$$ | $$ | $$ |\$$$$$$ |\$$$$$$$ |\$$$$$$ |$$ |\$$$$$$$\ $$$$$$$ |
# * \_______/ \__| \__|\__| \____/ \__| \__| \__| \______/ \_______| \______/ \__| \_______|\_______/
# *
# *
# * © Copyright 2023
# *
# * https://t.me/shitmodules
# *
# 🔒 Code is licensed under CC-BY-NC-ND 4.0 unless otherwise specified.
# 🌐 https://creativecommons.org/licenses/by-nc-nd/4.0/
# You CANNOT edit this file without direct permission from the author.
# You can redistribute this file without any changes.
# scope: hikka_only
# scope: hikka_min 1.6.3
# meta pic: https://x0.at/TPOM.png
# meta banner:
# meta developer: @shitmodules
import logging
import requests
from .. import loader, utils # type: ignore
from hikkatl.types import Message # type: ignore
logger = logging.getLogger(__name__)
@loader.tds
class QuoteGen(loader.Module):
"""Generation quote"""
strings = {
"name": "QuoteGen",
"loading": "<emoji document_id=5289930378885214069>✍️</emoji><b>Search for a quote...</b>",
"result": "<b><blockquote>{}</blockquote>\n\n<emoji document_id=5247213725080890199>©️</emoji><i>{}</i></b>",
"err": "<b>An error occurred, please try later</b>",
}
def __init__(self):
self.name = self.strings["name"]
async def client_ready(self, client, db):
self._client = client
self._db = db
@loader.command()
async def qn(self, message: Message):
"""Usage: .qn"""
await utils.answer(message, self.strings["loading"])
data = (await utils.run_sync(requests.get, "https://api.quotable.io/random")).json()
if data:
await utils.answer(message, self.strings["result"].format(data.get("content"), data.get("author")))
else:
await utils.answer(message, self.strings["err"])