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

Method add_member

ehforwarderbot/chat.py:502–540  ·  view source on GitHub ↗

Add a member to the chat. Tip: This method does not check for duplicates. Only add members with this method if you are sure that they are not added yet. To check if the member is already added before adding, you can do something like this:

(self, name: str, uid: ChatID, alias: Optional[str] = None,
                   id: ChatID = ChatID(""),
                   vendor_specific: Dict[str, Any] = None, description: str = "",
                   middleware: Optional[Middleware] = None)

Source from the content-addressed store, hash-verified

500 return s
501
502 def add_member(self, name: str, uid: ChatID, alias: Optional[str] = None,
503 id: ChatID = ChatID(""),
504 vendor_specific: Dict[str, Any] = None, description: str = "",
505 middleware: Optional[Middleware] = None) -> ChatMember:
506 """Add a member to the chat.
507
508 Tip:
509 This method does not check for duplicates. Only add members with this
510 method if you are sure that they are not added yet. To check if
511 the member is already added before adding, you can do something like
512 this:
513
514 .. code-block:: python
515
516 with contextlib.suppress(KeyError):
517 return chat.get_member(uid)
518 return chat.add_member(name, uid, alias=..., vendor_specific=...)
519
520 Args:
521 name (str): Name of the member.
522 uid: ID of the member.
523
524 Keyword Args:
525 alias (Optional[str]): Alias of the member.
526 vendor_specific (Dict[str, Any]): Any vendor specific attributes.
527 description (str):
528 A text description of the chat, usually known as “bio”,
529 “description”, “purpose”, or “topic” of the chat.
530 middleware (Optional[:class:`.Middleware`]): Initialize this chat as a part
531 of a middleware.
532 """
533 if id:
534 warnings.warn("`id` argument is deprecated, use `uid` instead.", DeprecationWarning)
535 uid = uid or id
536 member = ChatMember(self, name=name, alias=alias, uid=uid,
537 vendor_specific=vendor_specific, description=description,
538 middleware=middleware)
539 self.members.append(member)
540 return member
541
542 def make_system_member(self, name: str = "", alias: Optional[str] = None, id: ChatID = ChatID(""),
543 uid: ChatID = ChatID(""),

Callers 3

test_add_memberFunction · 0.80
__init__Method · 0.80
__init__Method · 0.80

Calls 1

ChatMemberClass · 0.85

Tested by 1

test_add_memberFunction · 0.64