nerve/main.py
Gabriel Wilson ee0d8c579d Interactivity & storage overhaul complete.
Proof-of-concept adding and removing questions complete
2022-05-20 06:35:33 -04:00

32 lines
792 B
Python

import json
import nio
import simplematrixbotlib as botlib
import commands
data = json.loads(open('data.json').read())
creds = botlib.Creds(
data["homeserver"],
data['username'],
data['password']
)
bot = botlib.Bot(creds)
@bot.listener.on_message_event
async def faq(room, message):
result = commands.handle_command(message.sender, message.body)
if result['response'] != None and result['response'] != "":
await bot.api.send_markdown_message(
room.room_id,
result['response']
)
@bot.listener.on_custom_event(nio.InviteMemberEvent)
async def example(room, event):
if event.membership == "join":
await bot.api.send_markdown_message(
room.room_id,
commands.get_faq_string()
)
bot.run()