pypufferblow.channels module#

class pypufferblow.channels.Channels(options: ChannelsOptions)[source]#

Bases: object

The underline class for managing the channels routes.

API_ROUTES#

The list of the API routes.

Type:

list[Route]

LIST_CHANNELS_API_ROUTE#

The list channels API route.

Type:

Route

CREATE_CHANNEL_API_ROUTE#

The create channel API route.

Type:

Route

DELETE_CHANNEL_API_ROUTE#

The delete channel API route.

Type:

Route

ADD_USER_TO_CHANNEL_API_ROUTE#

The add user to channel API route.

Type:

Route

REMOVE_USER_FROM_CHANNEL_API_ROUTE#

The remove user from channel API route.

Type:

Route

LOAD_MESSAGES_API_ROUTE#

The load messages API route.

Type:

Route

SEND_MESSAGE_API_ROUTE#

The send message API route.

Type:

Route

MARK_MESSAGE_AS_READ_API_ROUTE#

The mark message as read API route.

Type:

Route

DELETE_MESSAGE_API_ROUTE#

The delete message API route.

Type:

Route

ADD_USER_TO_CHANNEL_API_ROUTE: Route = <pypufferblow.models.route_model.Route object>#
API_ROUTES: list[Route] = [<pypufferblow.models.route_model.Route object>, <pypufferblow.models.route_model.Route object>, <pypufferblow.models.route_model.Route object>, <pypufferblow.models.route_model.Route object>, <pypufferblow.models.route_model.Route object>, <pypufferblow.models.route_model.Route object>, <pypufferblow.models.route_model.Route object>, <pypufferblow.models.route_model.Route object>, <pypufferblow.models.route_model.Route object>]#
CREATE_CHANNEL_API_ROUTE: Route = <pypufferblow.models.route_model.Route object>#
DELETE_CHANNEL_API_ROUTE: Route = <pypufferblow.models.route_model.Route object>#
DELETE_MESSAGE_API_ROUTE: Route = <pypufferblow.models.route_model.Route object>#
LIST_CHANNELS_API_ROUTE: Route = <pypufferblow.models.route_model.Route object>#
LOAD_MESSAGES_API_ROUTE: Route = <pypufferblow.models.route_model.Route object>#
MARK_MESSAGE_AS_READ_API_ROUTE: Route = <pypufferblow.models.route_model.Route object>#
REMOVE_USER_FROM_CHANNEL_API_ROUTE: Route = <pypufferblow.models.route_model.Route object>#
SEND_MESSAGE_API_ROUTE: Route = <pypufferblow.models.route_model.Route object>#
add_user(channel_id: str, user_id: str) None[source]#

Add a user to a channel.

Parameters:
  • channel_id (str) – The channel’s id.

  • user_id (str) – The user’s id.

Returns:

None.

Example

>>> channel_id = "6da0492c-631e-53f0-8f9f-2cbab5045351"
>>> user_id = "9ad0dc2f-536v-43f5-x6g4-2dfbh564234"
>>> client.channels.add_user(channel_id, user_id)
create_channel(channel_name: str, is_private: bool | None = False) None[source]#

Create a new channel.

Parameters:
  • channel_name (str) – The channel’s name.

  • (bool (is_private) – False): The channel’s type.

  • default – False): The channel’s type.

Returns:

None.

Example

>>> channel = client.channels.create_channel(
...    "general"
... )
delete_channel(channel_id: str) None[source]#

Delete a channel.

Parameters:

channel_id (str) – The channel’s id.

Returns:

None.

Example

>>> channel_id = "6da0492c-631e-53f0-8f9f-2cbab5045351"
>>> client.channels.delete_channel("channel_id")
delete_message(channel_id: str, message_id: str)[source]#

Delete a message in a channel.

Parameters:
  • channel_id (str) – The channel’s id.

  • message_id (str) – The message’s id.

Returns:

None.

Example

>>> channel_id = "6da0492c-631e-53f0-8f9f-2cbab5045351"
>>> message_id = "9ad0dc2f-536v-43f5-x6g4-2dfbh564234"
>>> client.channels.delete_message(
...    channel_id=channel_id,
...    message_id=message_id
... )
get_channel_info(channel_id: str) ChannelModel[source]#

Get the channel info.

Parameters:

channel_id (str) – The channel’s id.

Returns:

A ChannelModel object containing the channel info.

Return type:

ChannelModel

Example

>>> client.channels.get_channel_info()
list_channels() list[ChannelModel][source]#

List the channels.

Parameters:

None.

Returns:

A list of ChannelModel objects.

Return type:

list[ChannelModel]

load_messages(channel_id: str) list[MessageModel][source]#

Load messages from a channel.

Parameters:

channel_id (str) – The channel’s id.

Returns:

A list of MessageModel objects.

Return type:

list[MessageModel]

Example

>>> channel_id = "6da0492c-631e-53f0-8f9f-2cbab5045351"
>>> messages = client.channels.load_messages(
...    channel_id=channel_id
... )
mark_message_as_read(channel_id: str, message_id: str) None[source]#

Mark as a message as being red.

Parameters:
  • channel_id (str) – The channel’s id.

  • message_id (str) – The message’s id.

Returns:

None.

Example

>>> channel_id = "6da0492c-631e-53f0-8f9f-2cbab5045351"
>>> message_id = "9ad0dc2f-536v-43f5-x6g4-2dfbh564234"
>>> client.channels.mark_message_as_read(
...    channel_id=channel_id,
...    message_id=message_id
... )
remove_user(channel_id: str, user_id: str) None[source]#

Remove a user from a channel.

Parameters:
  • channel_id (str) – The channel’s id.

  • user_id (str) – The user’s id.

Returns:

None.

Example

>>> channel_id = "6da0492c-631e-53f0-8f9f-2cbab5045351"
>>> user_id = "9ad0dc2f-536v-43f5-x6g4-2dfbh564234"
>>> client.channels.remove_user(channel_id, user_id)
send_message(channel_id: str, message: str) None[source]#

Send a message in a channel.

Parameters:
  • channel_id (str) – The channel’s id.

  • message (str) – The message to send.

Returns:

None.

Example

>>> channel_id = "6da0492c-631e-53f0-8f9f-2cbab5045351"
>>> message = "Hello World"
>>> client.channels.send_message(
...    channel_id=channel_id,
...    message=message
... )