instanciate the matrix client
This commit is contained in:
parent
1172db1d95
commit
eb8cdefab4
2 changed files with 21 additions and 1 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -138,3 +138,6 @@ dmypy.json
|
||||||
# Cython debug symbols
|
# Cython debug symbols
|
||||||
cython_debug/
|
cython_debug/
|
||||||
|
|
||||||
|
# Project specific:
|
||||||
|
.sync_token
|
||||||
|
config.yaml
|
||||||
|
|
|
@ -1,14 +1,31 @@
|
||||||
import argparse
|
import argparse
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
|
from matrix_bot.client import Client
|
||||||
|
from matrix_bot.invite_policy import WhiteList
|
||||||
from .config import load_config
|
from .config import load_config
|
||||||
|
|
||||||
async def main():
|
async def main():
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument("-c", "--config", default="config.yaml")
|
parser.add_argument("-c", "--config", default="config.yaml")
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
config = load_config(args.config)
|
config = load_config(args.config)
|
||||||
print(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__":
|
if __name__ == "__main__":
|
||||||
asyncio.run(main())
|
asyncio.run(main())
|
||||||
|
|
Loading…
Reference in a new issue