nerve/main.py
2022-08-09 15:39:51 -04:00

32 lines
796 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 message(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()