plugable-matrix-bot/run.py
Dennis eb2b887c0a Transitioned from JSON to Hjson. Closes #3
All configuration files and all messages files should now preferrable be
done in Hjson. This format supports, i.a. features, multi line strings
and commenting. This greatly improves readability.

All installation and documentation files are also updated in this
commit.
2019-01-14 23:47:38 +01:00

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()