|
|
|
@ -9,6 +9,7 @@ from typing import (
|
|
|
|
|
)
|
|
|
|
|
from matrix_bot.client import Client
|
|
|
|
|
from matrix_bot.invite_policy import WhiteList
|
|
|
|
|
from .config import Config
|
|
|
|
|
from .format import Message
|
|
|
|
|
|
|
|
|
|
async def __send_messsages(
|
|
|
|
@ -31,27 +32,24 @@ async def __send_messsages(
|
|
|
|
|
|
|
|
|
|
async def send_messages(
|
|
|
|
|
message_queue: asyncio.Queue[dict[str, Any]], # For now, type will change in the futur
|
|
|
|
|
username: str,
|
|
|
|
|
homeserver: str,
|
|
|
|
|
password: str,
|
|
|
|
|
alert_rooms: list[str]
|
|
|
|
|
config: Config
|
|
|
|
|
):
|
|
|
|
|
"""
|
|
|
|
|
Initialize the bot and send messages added to the queue to the alert_rooms.
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
bot = await Client(
|
|
|
|
|
username,
|
|
|
|
|
homeserver,
|
|
|
|
|
password
|
|
|
|
|
config.username,
|
|
|
|
|
config.homeserver,
|
|
|
|
|
config.password
|
|
|
|
|
)
|
|
|
|
|
invite_policy = await WhiteList(bot, alert_rooms)
|
|
|
|
|
invite_policy = await WhiteList(bot, config.alert_rooms)
|
|
|
|
|
bot.set_invite_policy(invite_policy)
|
|
|
|
|
await asyncio.gather(
|
|
|
|
|
bot.run(),
|
|
|
|
|
__send_messsages(
|
|
|
|
|
message_queue,
|
|
|
|
|
bot,
|
|
|
|
|
alert_rooms
|
|
|
|
|
config.alert_rooms
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|