A group chat, where there are usually multiple members present. Members can be added with the :meth:`.add_member` method. If the ``with_self`` argument is ``True`` (which is the default setting), the User Themself would also be initialized as a member of the chat. Examples:
| 722 | |
| 723 | |
| 724 | class GroupChat(Chat): |
| 725 | """A group chat, where there are usually multiple members present. |
| 726 | |
| 727 | Members can be added with the :meth:`.add_member` method. |
| 728 | |
| 729 | If the ``with_self`` argument is ``True`` (which is the default setting), |
| 730 | the User Themself would also be initialized as a member of the chat. |
| 731 | |
| 732 | Examples: |
| 733 | |
| 734 | >>> group = GroupChat(channel=slave_channel, name="Wonderland", uid=ChatID("wonderland001")) |
| 735 | >>> group.add_member(name="Alice", uid=ChatID("alice")) |
| 736 | ChatMember(chat=<GroupChat: Wonderland (wonderland001) @ Example slave channel>, name='Alice', alias=None, uid='alice', vendor_specific={}, description='') |
| 737 | >>> group.add_member(name="bob", alias="Bob James", uid=ChatID("bob")) |
| 738 | ChatMember(chat=<GroupChat: Wonderland (wonderland001) @ Example slave channel>, name='bob', alias='Bob James', uid='bob', vendor_specific={}, description='') |
| 739 | >>> from pprint import pprint |
| 740 | >>> pprint(group.members) |
| 741 | [SelfChatMember(chat=<GroupChat: Wonderland (wonderland001) @ Example slave channel>, name='You', alias=None, uid='__self__', vendor_specific={}, description=''), |
| 742 | ChatMember(chat=<GroupChat: Wonderland (wonderland001) @ Example slave channel>, name='Alice', alias=None, uid='alice', vendor_specific={}, description=''), |
| 743 | ChatMember(chat=<GroupChat: Wonderland (wonderland001) @ Example slave channel>, name='bob', alias='Bob James', uid='bob', vendor_specific={}, description='')] |
| 744 | |
| 745 | Note: |
| 746 | ``GroupChat`` objects are picklable, thus it is RECOMMENDED |
| 747 | to keep any object of its subclass also picklable. |
| 748 | """ |
| 749 | |
| 750 | def __init__(self, *, channel: Optional[SlaveChannel] = None, middleware: Optional[Middleware] = None, |
| 751 | module_name: str = "", channel_emoji: str = "", module_id: ModuleID = ModuleID(""), name: str = "", |
| 752 | alias: Optional[str] = None, id: ChatID = ChatID(""), uid: ChatID = ChatID(""), vendor_specific: Dict[str, Any] = None, |
| 753 | description: str = "", notification: ChatNotificationState = ChatNotificationState.ALL, |
| 754 | with_self: bool = True): |
| 755 | super().__init__(channel=channel, middleware=middleware, module_name=module_name, channel_emoji=channel_emoji, |
| 756 | module_id=module_id, name=name, alias=alias, id=id, uid=uid, vendor_specific=vendor_specific, |
| 757 | description=description, notification=notification, with_self=with_self) |
| 758 | self.verify() |
| 759 | |
| 760 | def verify(self): |
| 761 | super().verify() |
| 762 | assert all(isinstance(member, ChatMember) for member in self.members) |
no outgoing calls