A private chat, where usually only the User Themself and the other participant are in the chat. Chat bots SHOULD also be categorized under this type. There SHOULD only be at most one non-system member of the chat apart from the User Themself, otherwise it might lead to unintended be
| 633 | |
| 634 | |
| 635 | class PrivateChat(Chat): |
| 636 | """A private chat, where usually only the User Themself and the other |
| 637 | participant are in the chat. Chat bots SHOULD also be categorized under this |
| 638 | type. |
| 639 | |
| 640 | There SHOULD only be at most one non-system member of the chat apart from |
| 641 | the User Themself, otherwise it might lead to unintended behavior. |
| 642 | |
| 643 | This object is by default initialized with the other participant as its |
| 644 | member. |
| 645 | |
| 646 | If the ``with_self`` argument is ``True`` (which is the default setting), |
| 647 | the User Themself would also be initialized as a member of the chat. |
| 648 | |
| 649 | Args: |
| 650 | other: the other participant of the chat as a member |
| 651 | |
| 652 | Note: |
| 653 | ``PrivateChat`` objects are picklable, thus it is RECOMMENDED |
| 654 | to keep any object of its subclass also picklable. |
| 655 | """ |
| 656 | other: ChatMember |
| 657 | |
| 658 | def __init__(self, *, channel: Optional[SlaveChannel] = None, middleware: Optional[Middleware] = None, |
| 659 | module_name: str = "", channel_emoji: str = "", module_id: ModuleID = ModuleID(""), name: str = "", |
| 660 | alias: Optional[str] = None, id: ChatID = ChatID(""), uid: ChatID = ChatID(""), |
| 661 | vendor_specific: Dict[str, Any] = None, |
| 662 | description: str = "", notification: ChatNotificationState = ChatNotificationState.ALL, |
| 663 | with_self: bool = True, other_is_self: bool = False): |
| 664 | super().__init__(channel=channel, middleware=middleware, module_name=module_name, channel_emoji=channel_emoji, |
| 665 | module_id=module_id, name=name, alias=alias, id=id, uid=uid, vendor_specific=vendor_specific, |
| 666 | description=description, notification=notification, with_self=with_self) |
| 667 | if other_is_self and with_self: |
| 668 | assert self.self is not None |
| 669 | self.other = self.self |
| 670 | else: |
| 671 | self.other = self.add_member(name=name, alias=alias, uid=uid, vendor_specific=vendor_specific, |
| 672 | description=description) |
| 673 | self.verify() |
| 674 | |
| 675 | def verify(self): |
| 676 | super().verify() |
| 677 | assert all(isinstance(member, ChatMember) for member in self.members), \ |
| 678 | f"Some members of this chat is not a valid one: {self.members!r}" |
| 679 | |
| 680 | |
| 681 | class SystemChat(Chat): |
no outgoing calls