Wikipedia module initial commit
This commit is contained in:
parent
bd8f574572
commit
9af7a4228b
|
@ -1,5 +1,4 @@
|
||||||
import re
|
import re
|
||||||
import html
|
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
|
@ -14,12 +13,7 @@ class MatrixModule(BotModule):
|
||||||
async def matrix_message(self, bot, room, event):
|
async def matrix_message(self, bot, room, event):
|
||||||
args = event.body.split()
|
args = event.body.split()
|
||||||
|
|
||||||
if len(args) == 3 and args[1] == 'apikey':
|
if len(args) > 1:
|
||||||
bot.must_be_owner(event)
|
|
||||||
self.api_key = args[2]
|
|
||||||
bot.save_settings()
|
|
||||||
await bot.send_text(room, 'Api key set')
|
|
||||||
elif len(args) > 1:
|
|
||||||
query = event.body[len(args[0])+1:]
|
query = event.body[len(args[0])+1:]
|
||||||
try:
|
try:
|
||||||
response = requests.get(self.api_url, params={
|
response = requests.get(self.api_url, params={
|
||||||
|
@ -67,9 +61,4 @@ class MatrixModule(BotModule):
|
||||||
await bot.send_text(room, 'Usage: !wikipedia <query>')
|
await bot.send_text(room, 'Usage: !wikipedia <query>')
|
||||||
|
|
||||||
def help(self):
|
def help(self):
|
||||||
return ('Wikipedia bot')
|
return ('Wikipedia bot')
|
||||||
|
|
||||||
def get_settings(self):
|
|
||||||
data = super().get_settings()
|
|
||||||
data["api_key"] = self.api_key
|
|
||||||
return data
|
|
Loading…
Reference in New Issue