-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogger.py
More file actions
26 lines (23 loc) · 943 Bytes
/
logger.py
File metadata and controls
26 lines (23 loc) · 943 Bytes
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
'''
Script for logging updates sent through Discord
'''
import discord
from mw_api_client import Wiki
from configuration import WIKI_API_URL, WIKI_PASSWORD, WIKI_USERAGENT, WIKI_USERNAME, DISCORD_PREFIX, DISCORD_TOKEN, WIKI_LOG_PAGE, WIKI_LOG_REV_SUMM_PREFIX
wiki = Wiki(WIKI_API_URL, WIKI_USERAGENT)
wiki.clientlogin(WIKI_USERNAME, WIKI_PASSWORD)
print("Logged in to wiki.")
class Bot(discord.Client):
async def on_ready(self):
print("Logged in to Discord.")
async def on_message(self, message):
if message.content.startswith(DISCORD_PREFIX):
content = message.content
content = content.replace(DISCORD_PREFIX, "")
page = wiki.page(WIKI_LOG_PAGE)
pagecontent = page.read()
pagecontent += "\n" + "* ~~~~~ - " + content
summ = WIKI_LOG_REV_SUMM_PREFIX + content
page.edit(pagecontent, summ)
client = Bot()
client.run(DISCORD_TOKEN)