You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
788 B
Python
32 lines
788 B
Python
import argparse
|
|
import asyncio
|
|
|
|
from matrix_bot.client import Client
|
|
from matrix_bot.invite_policy import WhiteList
|
|
from .config import load_config
|
|
|
|
async def main():
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument("-c", "--config", default="config.yaml")
|
|
args = parser.parse_args()
|
|
|
|
config = load_config(args.config)
|
|
client = await Client(
|
|
config.username,
|
|
config.homeserver,
|
|
config.password
|
|
)
|
|
invite_policy = await WhiteList(client, config.allert_rooms)
|
|
client.set_invite_policy(invite_policy)
|
|
|
|
# Test:
|
|
for room in config.allert_rooms:
|
|
await client.send_message(room, f"Hello from {config.username}")
|
|
|
|
await asyncio.gather(
|
|
client.run()
|
|
)
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(main())
|