semaphore.MessageSender
- class semaphore.MessageSender(username: str, socket: Socket, raise_errors: bool = False)[source]
Bases:
object
This class handles sending bot messages.
- async accept_invitation(group_id: str) None [source]
Accept a group invitation.
- Parameters:
group_id – Group id to accept invitation from
- async add_members(group_id: str, members: list) GroupV2 [source]
Add members to a group.
- Parameters:
group_id – Group id to add the members to
members – List of members uuids to be added
- Returns:
Returns the updated GroupV2 object
- async create_group(title: str, members: list) GroupV2 [source]
Create a Signal group.
- Parameters:
title – Title for the new group.
members – List of members uuids to be added to the new group
- Returns:
Returns the created GroupV2 object
- async get_group(group_id: str) GroupV2 [source]
Get details of a group.
- Parameters:
group_id – Group id to get details for
- Returns:
Returns a GroupV2 object
- async get_profile(message: Message) Profile [source]
Get Signal profile of message sender.
- Parameters:
message – The Signal message you received.
- Returns:
Signal profile
- async leave_group(group_id: str) GroupV2 [source]
Leave a Signal group.
- Parameters:
group_id – Identifier of the group to leave
- Returns:
Returns a GroupV2 object
- async list_groups() List[GroupV2] [source]
List groups for an account.
- Returns:
Returns a list of v2 group objects
- async mark_read(message: Message) None [source]
Mark a Signal message you received as read.
- Parameters:
message – The Signal message you received.
- async preview_group(url: str) GroupV2 [source]
Preview information about a group without joining.
- Parameters:
url – Group invite link to preview information for
- Returns:
Returns a GroupV2 object
- async remove_members(group_id: str, members: list) GroupV2 [source]
Remove members from a group.
- Parameters:
group_id – Group id to remove the members from
members – List of members uuids to be removed
- Returns:
Returns the updated GroupV2 object
- async reply_message(message: Message, reply: Reply) bool [source]
Send the bot message.
- Parameters:
message – The original message replying to.
reply – The reply to send.
- Returns:
Returns whether replying is successful.
- Return type:
bool
- async send_message(receiver: str, body: str, attachments: List[Attachment] | None = None, link_previews: List[LinkPreview] | None = None) bool [source]
Send a message.
- Parameters:
receiver – The receiver of the message (uuid or number).
body – The body of the message.
attachments – Optional attachments to the message.
link_previews – Optional link previews for the message.
- Returns:
Returns whether sending is successful.
- Return type:
bool
- async set_expiration(receiver: str, time: int) None [source]
Set the message expiration timer for a chat.
- Parameters:
receiver – The receiver for which to set the expiration time.
time – Time must be specified in seconds, set to 0 to disable timer.
- async set_profile(profile_name: str, profile_avatar: str | None = None, profile_emoji: str | None = None, profile_about: str | None = None) None [source]
Set Signal profile.
- Parameters:
profile_name – New profile name, empty string for no profile name.
profile_avatar – Path to profile avatar file.
profile_emoji – Emoji character visible in profile.
profile_about – Description text visible in profile.
- async typing_started(message: Message) None [source]
Send a typing started message.
- Parameters:
message – The Signal message you received.
- async typing_stopped(message: Message) None [source]
Send a typing stopped message.
- Parameters:
message – The Signal message you received.
- async update_group_access_control(group_id: str, access_control: str, role: str) GroupV2 [source]
Change a group’s access control.
- Parameters:
group_id – Identifier of the group to update avatar for
access_control – Name of the access control, options are: attributes|members|link
role – Set the role of an access control: for attributes otions are: UNSATISFIABLE|ADMINISTRATOR|ANY for members otions are: MEMBER|ADMINISTRATOR for link options are: MEMBER|ADMINISTRATOR
- Returns:
Returns the updated GroupV2 object
- async update_group_avatar(group_id: str, group_avatar: str) GroupV2 [source]
Change a group’s avatar.
- Parameters:
group_id – Identifier of the group to update avatar for
group_avatar – Path to group avatar file
- Returns:
Returns the updated GroupV2 object
- async update_group_role(group_id: str, member_id: str, role: str) GroupV2 [source]
Update the role of a member in the group.
- Parameters:
group_id – Identifier of the group to update member role for
member_id – Identifier of the member
role – Updated role of the member
- Returns:
Returns the updated GroupV2 object