MCPcopy Create free account
hub / github.com/ehForwarderBot/ehForwarderBot / PrivateChat

Class PrivateChat

ehforwarderbot/chat.py:635–678  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

633
634
635class 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
681class SystemChat(Chat):

Callers 10

test_copyFunction · 0.90
test_verify_valid_chatFunction · 0.90
test_verify_missing_uidFunction · 0.90
test_pickleFunction · 0.90
test_propertiesFunction · 0.90
test_private_otherFunction · 0.90
__init__Method · 0.90

Calls

no outgoing calls

Tested by 9

test_copyFunction · 0.72
test_verify_valid_chatFunction · 0.72
test_verify_missing_uidFunction · 0.72
test_pickleFunction · 0.72
test_propertiesFunction · 0.72
test_private_otherFunction · 0.72