26 lines
954 B
Python
26 lines
954 B
Python
from asgiref.sync import async_to_sync
|
|
from nio import RoomPreset
|
|
|
|
from corres2math.matrix import Matrix, RoomVisibility
|
|
from django.core.management import BaseCommand
|
|
from registration.models import AdminRegistration
|
|
|
|
|
|
class Command(BaseCommand):
|
|
def handle(self, *args, **options):
|
|
Matrix.set_display_name("Bot des Correspondances")
|
|
|
|
if not async_to_sync(Matrix.resolve_room_alias)("#faq:correspondances-maths.fr"):
|
|
Matrix.create_room(
|
|
visibility=RoomVisibility.public,
|
|
alias="faq",
|
|
name="FAQ",
|
|
topic="Posez toutes vos questions ici !",
|
|
federate=False,
|
|
preset=RoomPreset.public_chat,
|
|
)
|
|
|
|
for admin in AdminRegistration.objects.all():
|
|
Matrix.set_room_power_level("#faq:correspondances-maths.fr",
|
|
f"@{admin.matrix_username}:correspondances-maths.fr", 95)
|