26 lines
724 B
Python
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()
|