plugable-matrix-bot/plugins/hello/hello.py
Dennis 0d32c727fa Added installation files
This commit adds a convenient installation script for Linux and also
adds a description on how to install the bot.

Furthermore, a very simple example plugin is added. This way, new users
can easily discover the possibilities of this plugin.

Finally, the default character "Peter"---which is used within
Alcuinus---is removed, and a more generic character is added.
2019-01-12 15:13:21 +01:00

26 lines
724 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.info_callback))
# Save parent bot
self.bot = bot
def info_callback(self, room, event):
room.send_text(f"Hello {event['sender']}!")
def help(self):
return open(HELP_LOCATION, mode="r").read()