TexLiLy/main.py
LoaD Accumulator dff9dd2683
[ADD] Add basic support for custom styles in LaTeX
I still need to fix that syncing issue.
2023-06-13 16:36:36 +02:00

46 lines
1.2 KiB
Python

from nio import *
import asyncio
import utils
async def main() -> None:
import callbacks
import yaml
# Load our config file.
config = {}
try:
with open('texlily.yaml', 'r') as conf:
config = yaml.safe_load(conf)
# Retrieve our configuration
homeserver = str(config["homeserver"])
user = str(config["user"])
token = str(config["token"])
path = str(config["data"]) # Unused there, required.
utils.set_config(config)
# if config file does not exist, quit
except FileNotFoundError:
print("No config file found.")
print("Please create a file named `texlily.yaml` and read the README file.")
quit()
except TypeError:
print("Invalid configuration file.")
quit()
client = AsyncClient(homeserver)
client.access_token = token
client.user_id = user
# TODO: Fix this hot mess before merging onto main.
client.sync(timeout=10000)
# Register all of the callbacks
utils.set_client(client)
client.add_event_callback(callbacks.msg_cb, RoomMessageText)
client.add_event_callback(callbacks.file_cb, RoomMessageFile)
await client.sync_forever(timeout=10000, full_state=True)
asyncio.run(main())