plugable-matrix-bot/run.py

45 lines
1.0 KiB
Python
Executable File

#!/usr/bin/env python3
"""
This is Peter. Peter is using the Python Matrix Bot API
"""
__author__ = "Dennis Potter"
__copyright__ = "Copyright 2019, Dennis Potter"
__credits__ = ["Dennis Potter"]
__license__ = "GPL-3.0"
__version__ = "0.5.0"
__maintainer__ = "Dennis Potter"
__email__ = "dennis@dennispotter.eu"
import hjson
import os
import time
import threading
# Bot API import
from matrix_bot_api.matrix_bot_api import MatrixBotAPI
CONFIG_LOCATION = os.path.join(os.path.dirname(__file__), 'config.hjson')
def main():
# Load the configuration
with open(CONFIG_LOCATION) as hjson_data:
config = hjson.load(hjson_data)
# Create an instance of the MatrixBotAPI
bot = MatrixBotAPI(config)
# Start polling
bot.start_polling()
# Stall this thread while the bot runs in other threads. On ^C, this will
# indicate to all threads that they should cancel
try:
forever = threading.Event();
forever.wait()
except:
bot.cancel = True
if __name__ == "__main__":
main()