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.
46 lines
1.2 KiB
Python
46 lines
1.2 KiB
Python
"""
|
|
Not really tests, because I don't know how to testt without a whole matrix server.
|
|
"""
|
|
|
|
import asyncio
|
|
import logging
|
|
import os
|
|
from dotenv import load_dotenv
|
|
from matrix_bot.client import Client
|
|
from matrix_bot.invite_policy import (
|
|
AcceptAll,
|
|
DeclineAll,
|
|
WhiteList
|
|
)
|
|
from getpass import getpass
|
|
|
|
logging.basicConfig(format="%(levelname)s: %(message)s", level=logging.DEBUG)
|
|
|
|
async def main():
|
|
load_dotenv()
|
|
client = await Client(
|
|
os.environ["MUSER"],
|
|
os.environ["HOMESERVER"],
|
|
os.environ["PASSWD"],
|
|
)
|
|
withelisted_room_names = os.environ["ROOMS"].split(",")
|
|
whitelist_policy = await WhiteList(client, withelisted_room_names)
|
|
room_name = withelisted_room_names[0]
|
|
client.set_invite_policy(whitelist_policy)
|
|
await client.send_message(room_name, "Beware of Greeks bearing gifts")
|
|
await asyncio.sleep(5)
|
|
await client.send_firework_message(room_name, "fire")
|
|
await asyncio.sleep(5)
|
|
await client.send_confetti_message(room_name, "confetti")
|
|
await asyncio.sleep(5)
|
|
await client.send_snow_message(room_name, "snow")
|
|
await asyncio.sleep(5)
|
|
await client.send_space_invader_message(room_name, "space")
|
|
await client.run()
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(main())
|
|
|