¶
botcity.plugins.slack.plugin.BotSlackPlugin
¶
client
property
readonly
¶
Slack client instance.
Returns:
Type | Description |
---|---|
client |
The slack client instance. |
__init__(self, slack_token, channel, **kwargs)
special
¶
BotSlackPlugin.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
slack_token |
str |
Authentication token. |
required |
channel |
str |
Channel or private group to send message to. Can be an ID, or a name. |
required |
delete_file(self, response)
¶
Delete file based on the response of upload file passed as argument.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
upload |
file (Response |
Response of upload file. |
required |
Returns:
Type | Description |
---|---|
response |
delete file response. |
delete_message(self, response)
¶
Delete the message based on the response passed as argument.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message |
Response |
The response of sended message. |
required |
Returns:
Type | Description |
---|---|
response |
delete message response. |
get_replies(self, response, **kwargs)
¶
Update the message based on the response passed as argument.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message |
Response |
The response of sent message. |
required |
Returns:
Type | Description |
---|---|
List[Message] |
List of replies. |
get_text_replies(self, response)
¶
Get the text of the message replied to in the thread based on the response passed as argument.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
replies |
Response |
The response of get replies. |
required |
Returns:
Type | Description |
---|---|
List[str] |
List of messages replies as string. |
reply(self, response, msg, **kwargs)
¶
Reply to a previously received message.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message |
Response |
The response of sent message. |
required |
msg |
str |
The message to reply. |
required |
Returns:
Type | Description |
---|---|
response |
send message response. |
send_message(self, message, attachment=True, channel=None, users=None, **kwargs)
¶
Send a more elaborate message via attachment.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message |
Message |
The full content of the message.See Message. |
required |
attachment |
dict |
For a message with attachment keep Default True. |
True |
channel |
str |
Channel or private group to send message to. Can be an ID, or a name. |
None |
users |
str |
The usernames for mentions. |
None |
Returns:
Type | Description |
---|---|
response |
send message response. |
send_simple_message(self, text, channel=None, users=None, attachment=False, **kwargs)
¶
Send a simple message.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text |
str |
The text of message. |
required |
channel |
str |
Channel or private group to send message to. Can be an ID, or a name. |
None |
users |
str |
The usernames for mentions |
None |
attachment |
dict |
For a simple message keep Default false. |
False |
Returns:
Type | Description |
---|---|
response |
send message response. |
update_message(self, response, text, users=None)
¶
Update the message based on the response passed as argument.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message |
Response |
The response of sended message. |
required |
text |
str |
The new text for message update. |
required |
users |
str |
The usernames for mentions. |
None |
Returns:
Type | Description |
---|---|
response |
update message response. |
upload_file(self, file, channel=None, text_for_file=None, title_for_file=None)
¶
Upload file to slack.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file |
str |
The file path. |
required |
channel |
str |
Channel or private channel to send message to. Can be an ID, or a name. |
None |
text_for_file |
str |
The text that comes before the file upload. |
None |
text_for_file |
str |
The File title. |
None |
Returns:
Type | Description |
---|---|
response |
upload file response. |
wait_for_reply(self, response, timeout=300)
¶
Wait for a new message until a timeout.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message |
Response |
The response of sent message. |
required |
timeout |
int |
The maximum waiting time (in seconds). Defaults to 300s. |
300 |
Returns:
Type | Description |
---|---|
List[dict] |
The dict to text and member. |
botcity.plugins.slack.models.Message
dataclass
¶
The message with attachment.
Attributes:
Name | Type | Description |
---|---|---|
text |
str |
The main text of the message content. |
title |
str |
Title text near the top of the message. |
pretext |
str |
Text that appears above the message block. |
thumb_url |
str |
A valid URL to an image file that will be displayed as a thumbnail on the right side of a message attachment. |
author |
Author |
Author information. |
footer |
Footer |
Footer texts. |
ts |
Optional[int] |
The timestamp value as part of the message footer. |
fields |
List[botcity.plugins.slack.models.Field] |
List of Field information. |
fallback |
Optional[str] |
A plain text summary of the attachment used in clients that don't show formatted text. |
color |
Union[botcity.plugins.slack.models.Color, str] |
Changes the color of the border on the left side of this message, the default color is gray. |
image_url |
Optional[str] |
A valid URL to an image file that will be displayed at the bottom of the message. We support GIF, JPEG, PNG, and BMP formats. |
title_link |
Optional[str] |
A valid URL that turns the title text into a hyperlink. |
markdown_in |
Optional[List[str]] |
An array of field names that should be formatted by mrkdwn syntax. |
botcity.plugins.slack.models.Color (Enum)
¶
The color type.
Attributes:
Name | Type | Description |
---|---|---|
RED |
str |
The red color. |
GRAY |
str |
The gray color. |
BLUE |
str |
The blue color. |
GREEN |
str |
The green color. |
WHITE |
str |
The white color. |
BLACK |
str |
The black color. |
BROWN |
str |
The brown color. |
YELLOW |
str |
The yellow color. |
PURPLE |
str |
The purple color. |
ORANGE |
str |
The orange color. |
botcity.plugins.slack.models.Author
dataclass
¶
Author info.
Attributes:
Name | Type | Description |
---|---|---|
author_name |
str |
The author name. |
author_icon |
str |
A valid URL that displays a small 16px by 16px image to the left of the author_name. |
author_link |
str |
A valid URL that will hyperlink the author_name text. |
botcity.plugins.slack.models.Footer
dataclass
¶
Footer in message.
Attributes:
Name | Type | Description |
---|---|---|
footer |
str |
A brief text that will be displayed footer. |
footer_icon |
str |
A valid URL to an image file that will be displayed beside the footer text. |
botcity.plugins.slack.models.Field
dataclass
¶
Fields are an array of field objects that get displayed in a table-like way.
Attributes:
Name | Type | Description |
---|---|---|
title |
str |
Title as bold heading displayed in the field object. |
value |
str |
The text value displayed in the field object. |
short |
bool |
Indicates whether the field object is short enough to be displayed side-by-side with other field objects. Defaults to false. |