-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
31 lines (26 loc) · 791 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import toml
import os
import simplematrixbotlib as botlib
import matrixmatrixbridge as mmb
def main() -> None:
config_path = os.environ.get("CONFIG_PATH", "config.toml")
try:
with open(config_path, "r") as f:
config = toml.loads(f.read())
except FileNotFoundError:
print(f"Config file not found at {config_path}")
return
homeserver=config["homeserver"]
username=config["username"]
try:
password=config["password"]
access_token = ""
except:
password = ""
access_token=config["access_token"]
creds = botlib.Creds(homeserver, username, password, access_token=access_token)
bot = botlib.Bot(creds)
mmb.setup_handlers(bot, config)
bot.run()
if __name__ == "__main__":
main()