-
Notifications
You must be signed in to change notification settings - Fork 22
/
wikipedia.py
34 lines (27 loc) · 965 Bytes
/
wikipedia.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
from pyrogram import Client, filters
from pyrogram.types import Message
from utils.misc import modules_help, prefix
from utils.scripts import import_library, format_exc
wikipedia = import_library("wikipedia")
@Client.on_message(filters.command("wiki", prefix) & filters.me)
async def wiki(_, message: Message):
lang = message.command[1]
user_request = " ".join(message.command[2:])
if user_request == "":
wikipedia.set_lang("ru")
user_request = " ".join(message.command[1:])
try:
if lang == "en":
wikipedia.set_lang("en")
result = wikipedia.summary(user_request)
await message.edit(
f"""<b>Request:</b>
<code>{user_request}</code>
<b>Result:</b>
<code>{result}</code>"""
)
except Exception as e:
await message.edit(format_exc(e))
modules_help["wikipedia"] = {
"wiki [lang]* [request]*": "Search in Russian Wikipedia",
}