forked from Abdur-rahmaanJ/honeybot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wikipedia.py
45 lines (35 loc) 路 1.14 KB
/
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
35
36
37
38
39
40
41
42
43
44
45
# -*- coding: utf-8 -*-
"""
[wikipedia.py]
Wikipedia Plugin
[Author]
Gabriele Ron
[About]
sends a wikipedia article on request based off of a search or random query
requires wikipedia library. Can use pip -> "pip install wikipedia"
[Website]
https://Macr0Nerd.github.io
[Commands]
>>> .wiki <command> <topic>
returns a wikipedia article
"""
import wikipedia
class Plugin:
def __init__(self):
pass
def run(self, incoming, methods, info):
# if '!~' in info['prefix']:
# print(info)
try:
msgs = info['args'][1:][0].split()
if info['command'] == 'PRIVMSG' and msgs[0] == '.wiki':
if msgs[1] == 'random':
print("You want the random article!")
article = wikipedia.page(wikipedia.random(1)).summary
methods['send'](info['address'], article)
elif msgs[1] == 'search':
print(f"You wanted {msgs[2]}")
article = wikipedia.page(msgs[2]).summary
methods['send'](info['address'], article)
except Exception as e:
print('woops plug', e)