From 19cc22a4791fe29cfe5a2c615cf626323aee3cc0 Mon Sep 17 00:00:00 2001 From: Jean-Marie Mineau Date: Mon, 4 Oct 2021 16:10:35 +0200 Subject: [PATCH] add simple invite policies --- src/matrix_bot/invite_policy.py | 45 +++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src/matrix_bot/invite_policy.py diff --git a/src/matrix_bot/invite_policy.py b/src/matrix_bot/invite_policy.py new file mode 100644 index 0000000..4c1588f --- /dev/null +++ b/src/matrix_bot/invite_policy.py @@ -0,0 +1,45 @@ +""" + InvitePolicy class: + InvitePolicy object are use to chose whether to accept or decline + an invite to a room. +""" + +from abc import ( + ABC, + abstractmethod +) +import nio + +class InvitePolicy(ABC): + """ + Class used by Client to chose whether to accept of decline an invite. + """ + + @abstractmethod + await def accept_invite( + self, + invite: nio.responses.InviteInfo + )->bool: + pass + +class DeclineAll(InvitePolicy): + """ + Decline all invitations. + """ + + await def accept_invite( + self, + invite: nio.responses.InviteInfo + )->bool: + return False + +class AcceptAll(InvitePolicy): + """ + Accept all invitations. + """ + + await def accept_invite( + self, + invite: nio.responses.InviteInfo + )->bool: + return True