add simple invite policies
This commit is contained in:
parent
ade9615a74
commit
19cc22a479
1 changed files with 45 additions and 0 deletions
45
src/matrix_bot/invite_policy.py
Normal file
45
src/matrix_bot/invite_policy.py
Normal file
|
@ -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
|
Loading…
Reference in a new issue