-
Notifications
You must be signed in to change notification settings - Fork 83
/
quotes.py
46 lines (40 loc) · 1.39 KB
/
quotes.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
# inspired from uniborg Quotes plugin
import random
from userbot import catub
from userbot.core.logger import logging
from userbot.core.managers import edit_delete, edit_or_reply
from userbot.helpers import catmemes
from userbot.helpers.functions import random_quote, search_quotes
from userbot.helpers.utils import parse_pre
LOGS = logging.getLogger(__name__)
plugin_category = "extra"
@catub.cat_cmd(
pattern="quote(?:\s|$)([\s\S]*)",
command=("quote", plugin_category),
info={
"header": "To get random quotes on given topic.",
"description": "An api that Fetchs random Quote from `goodreads.com`",
"usage": "{tr}quote <topic>",
"examples": "{tr}quote love",
},
)
async def quote_search(event):
"shows random quotes on given topic."
input_str = event.pattern_match.group(1)
try:
response = await search_quotes(input_str) if input_str else await random_quote()
except Exception:
return await edit_delete(event, "`Sorry Zero results found`", 5)
await edit_or_reply(event, response, parse_mode=parse_pre)
@catub.cat_cmd(
pattern="pquote$",
command=("pquote", plugin_category),
info={
"header": "To get random quotes on programming.",
"usage": "{tr}pquote",
},
)
async def _(event):
"Shows random programming quotes"
txt = random.choice(catmemes.PROGQUOTES)
await edit_or_reply(event, txt)