plugable-matrix-bot/plugins/hello/hello.py
Dennis a6919125ae Added plugin install API
It is now specified how a plugin should be installed. Furthermore, a
"super user" is added to the install script and configuration files.
2019-01-12 18:02:34 +01:00

29 lines
816 B
Python

from matrix_bot_api.mregex_handler import MRegexHandler
import os
HELP_LOCATION = os.path.join(os.path.dirname(__file__), 'messages/help')
class Plugin:
""" This is an example plugin with only a single callback. When
a user says "Hello bot" in a room in which te bot is present,
the user replies with "Hello <username>!".
"""
def __init__(self, bot):
# Define sensitivity
self.handler = []
self.handler.append(MRegexHandler("Hello bot", self.hello_callback))
# Save parent bot
self.bot = bot
def hello_callback(self, room, event):
room.send_text(f"Hello {event['sender']}!")
def help(self):
return open(HELP_LOCATION, mode="r").read()
def setup():
print("This function runs once, when the plugin is used the 1st time.")