duppla-slack 2024.12__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,16 @@
1
+ Copyright [2024] duppla
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software only within duppla, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all
8
+ copies or substantial portions of the Software.
9
+
10
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
11
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
12
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
13
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
14
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
15
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
16
+ SOFTWARE.
@@ -0,0 +1,22 @@
1
+ Metadata-Version: 2.1
2
+ Name: duppla_slack
3
+ Version: 2024.12
4
+ Summary: Custom implementation for Slack API
5
+ Author: duppla
6
+ Author-email: <>
7
+ Keywords: python,slack,duppla
8
+ Classifier: Development Status :: 1 - Planning
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Operating System :: Unix
12
+ Classifier: Operating System :: MacOS :: MacOS X
13
+ Classifier: Operating System :: Microsoft :: Windows
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ Requires-Dist: pydantic<3.0.0,>=2.10.0
17
+ Requires-Dist: requests
18
+ Requires-Dist: shortuuid
19
+ Requires-Dist: slack_sdk<4.0.0,>3.30.0
20
+ Requires-Dist: Unidecode
21
+
22
+ A custom implementation for Slack API using Python, based on the official API + SDK.
@@ -0,0 +1,17 @@
1
+ # Slack [Aplicacion interna de duppla]
2
+
3
+ La plataforma de Slack ofrece un SDK para poder interactuar con la API de Slack. Este paquete de Python está diseñado exclusivamente para el uso interno de duppla a través de los diversos repositorios de la organización.
4
+
5
+ > [!IMPORTANT]
6
+ > Este paquete no está disponible para su uso externo.
7
+
8
+ ## Instalación[^1]
9
+
10
+ ```bash
11
+ pip install git+https://<BOT TOKEN>@github.com/duppla/duppla_slack
12
+ ```
13
+
14
+ [^1]: Reemplace <BOT TOKEN> por el token de acceso del bot de github. (Preguntar a los administradores de la organización)
15
+
16
+ > [!NOTE]
17
+ > Para mas información sobre la API de Slack, visite [Slack API](https://api.slack.com/) y la librería de Python [Slack API](https://github.com/slackapi/python-slack-sdk)
@@ -0,0 +1,18 @@
1
+ from duppla_slack.constants.channels import (
2
+ AIRFLOW_CHANNEL as AIRFLOW_CHANNEL,
3
+ GENERAL_CHANNEL as GENERAL_CHANNEL,
4
+ RANDOM_CHANNEL as RANDOM_CHANNEL,
5
+ )
6
+ from duppla_slack.constants.templates import Filetype as Filetype
7
+ from duppla_slack.models import (
8
+ Attachment as Attachment,
9
+ AttachmentOld as AttachmentOld,
10
+ Bookmark as Bookmark,
11
+ EphemeralMessage as EphemeralMessage,
12
+ LongMessage as LongMessage,
13
+ Message as Message,
14
+ ScheduledMessage as ScheduledMessage,
15
+ SlackApiError as SlackApiError,
16
+ SlackProfile as SlackProfile,
17
+ )
18
+ from duppla_slack.service.public import SlackService as SlackService
@@ -0,0 +1,25 @@
1
+ from slack_sdk.errors import SlackApiError as SlackApiError
2
+
3
+ from .duppla import SlackProfile as SlackProfile
4
+
5
+ from .message import Message as Message # isort:skip
6
+ from .message import (
7
+ Attachment as Attachment,
8
+ AttachmentOld as AttachmentOld,
9
+ Bookmark as Bookmark,
10
+ EphemeralMessage as EphemeralMessage,
11
+ LongMessage as LongMessage,
12
+ ScheduledMessage as ScheduledMessage,
13
+ )
14
+
15
+ __all__ = [
16
+ "SlackProfile",
17
+ "Message",
18
+ "Attachment",
19
+ "AttachmentOld",
20
+ "Bookmark",
21
+ "EphemeralMessage",
22
+ "LongMessage",
23
+ "ScheduledMessage",
24
+ "SlackApiError",
25
+ ]
@@ -0,0 +1,18 @@
1
+ from typing import TypedDict
2
+
3
+
4
+ class SlackProfile(TypedDict):
5
+ real_name: str
6
+ real_name_normalized: str
7
+ display_name: str
8
+ display_name_normalized: str
9
+ status_text: str
10
+ status_emoji: str
11
+ email: str
12
+ image_24: str
13
+ image_32: str
14
+ image_48: str
15
+ image_72: str
16
+ image_192: str
17
+ image_512: str
18
+ is_bot: bool
@@ -0,0 +1,123 @@
1
+ from typing import Any, Literal, TypedDict
2
+ from pydantic import AliasChoices, BaseModel, Field
3
+
4
+ from duppla_slack.constants.channels import AIRFLOW_CHANNEL
5
+ from duppla_slack.constants.templates import Filetype
6
+
7
+
8
+ class Attachment(TypedDict, total=False):
9
+ """
10
+ Represents an attachment for a message to send to a Slack channel.
11
+ Check the official documentation of the Slack API for more information: https://api.slack.com/reference/messaging/attachments
12
+ """
13
+
14
+ title: str | None
15
+ value: str | None
16
+ short: bool
17
+ blocks: list[dict[str, Any]]
18
+ color: Literal["good", "warning", "danger"] | str
19
+
20
+
21
+ class AttachmentOld(TypedDict, total=False):
22
+ """
23
+ Represents an attachment for a message to send to a Slack channel.
24
+ Check the official documentation of the Slack API for more information: https://api.slack.com/reference/messaging/attachments
25
+ """
26
+
27
+ author_icon: str
28
+ author_link: str
29
+ author_name: str
30
+ fallback: str
31
+ fields: list[dict[str, Any]]
32
+ footer: str
33
+ footer_icon: str
34
+ image_url: str
35
+ mrkdwn_in: list[str]
36
+ pretext: str
37
+ text: str
38
+ thumb_url: str
39
+ title: str
40
+ title_link: str
41
+ ts: str | int
42
+
43
+
44
+ class Message(BaseModel):
45
+ """
46
+ Represents the body of the request to send a message to a Slack channel.
47
+ The body may contain attachments or blocks for rich content.
48
+ # NOTE:
49
+ - If the channel is a user ID, the message will be sent as a direct message to that user.
50
+ - If the thread_ts is set, the message will be sent as a reply to the specified thread and if the reply_broadcast is set to True, the message will also be sent to the entire channel.
51
+
52
+ > Check the official documentation of the Slack API for more information: https://api.slack.com/methods/chat.postMessage
53
+ """
54
+
55
+ text: str = Field(validation_alias=AliasChoices("text", "msg"))
56
+ channel: str = Field(default=AIRFLOW_CHANNEL, validation_alias=AliasChoices("channel", "channel_id")) # fmt:skip
57
+ thread_ts: str | None = None
58
+ reply_broadcast: bool | None = False
59
+ attachments: list[Attachment | AttachmentOld] | None = None
60
+ blocks: list[dict[str, Any]] | None = None
61
+
62
+
63
+ class LongMessage(BaseModel):
64
+ """
65
+ Represents the body of the request to send a long message to a Slack channel.
66
+ The message is sent as a file, to avoid the truncate originated from the 4000 characters limit of the text field.
67
+
68
+ # NOTE:
69
+ - If the channel is a user ID, it will thrown an error, pass instead a Direct Channel ID.
70
+ - The original method will be deprecated soon, so it is recommended to use the wrapper `files.uploadv2` of the actual two methods: `files.getUploadURLExternal` and `files.completeUploadExternal`
71
+
72
+ > Check the official documentation of the Slack API for more information:
73
+ > https://api.slack.com/methods/files.upload [Deprecated but shows the use of files.uploadv2]
74
+ > https://api.slack.com/methods/files.getUploadURLExternal
75
+ > https://api.slack.com/methods/files.completeUploadExternal
76
+ """
77
+
78
+ initial_comment: str | None = Field(default=None, validation_alias=AliasChoices("initial_comment", "msg", "text")) # fmt:skip
79
+ """The message to be sent as a header before the file."""
80
+ content: str
81
+ """A string representing the file content."""
82
+ channel: str = Field(default=AIRFLOW_CHANNEL, validation_alias=AliasChoices("channel", "channel_id")) # fmt:skip
83
+ """The channel ID or name where the message will be sent. (It must start with 'C', 'G', 'D' or 'Z', meaning channel, group, direct message or user respectively.)"""
84
+ thread_ts: str | int | None = None
85
+ reply_broadcast: bool = False
86
+ snippet_type: Filetype = Field(default="auto", validation_alias=AliasChoices("snippet_type", "type", "filetype")) # fmt:skip
87
+ """The type of the file content to display following the snippet format, see https://api.slack.com/types/file#types"""
88
+
89
+
90
+ class EphemeralMessage(Message):
91
+ """
92
+ Represents the body of the request to send an ephemeral message to a Slack user.
93
+ The body (like the parent class Message) may contain attachments or blocks for rich content.
94
+ # NOTE: If the channel is a user ID, the message will be sent as a direct message to that user.
95
+ > Check the official documentation of the Slack API for more information: https://api.slack.com/methods/chat.postEphemeral
96
+ """
97
+
98
+ user: str
99
+
100
+
101
+ class ScheduledMessage(Message):
102
+ """
103
+ Represents the body of the request to schedule a message to a Slack channel.
104
+ The body (like the parent class Message) may contain attachments or blocks for rich content.
105
+ # NOTE: If the channel is a user ID, the message will be sent as a direct message to that user.
106
+ > Check the official documentation of the Slack API for more information: https://api.slack.com/methods/chat.scheduleMessage
107
+ """
108
+
109
+ post_at: int # Unix time
110
+ reply_broadcast: bool | None = False
111
+
112
+
113
+ class Bookmark(BaseModel):
114
+ """
115
+ Represents a bookmark for a message to send to a Slack channel.
116
+ Check the official documentation of the Slack API for more information: https://api.slack.com/reference/messaging/blocks
117
+ """
118
+
119
+ channel_id: str
120
+ title: str
121
+ type: str
122
+ emoji: str | None = None
123
+ link: str | None = None
File without changes
@@ -0,0 +1,22 @@
1
+ Metadata-Version: 2.1
2
+ Name: duppla_slack
3
+ Version: 2024.12
4
+ Summary: Custom implementation for Slack API
5
+ Author: duppla
6
+ Author-email: <>
7
+ Keywords: python,slack,duppla
8
+ Classifier: Development Status :: 1 - Planning
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Operating System :: Unix
12
+ Classifier: Operating System :: MacOS :: MacOS X
13
+ Classifier: Operating System :: Microsoft :: Windows
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ Requires-Dist: pydantic<3.0.0,>=2.10.0
17
+ Requires-Dist: requests
18
+ Requires-Dist: shortuuid
19
+ Requires-Dist: slack_sdk<4.0.0,>3.30.0
20
+ Requires-Dist: Unidecode
21
+
22
+ A custom implementation for Slack API using Python, based on the official API + SDK.
@@ -0,0 +1,13 @@
1
+ LICENSE
2
+ README.md
3
+ setup.py
4
+ duppla_slack/__init__.py
5
+ duppla_slack.egg-info/PKG-INFO
6
+ duppla_slack.egg-info/SOURCES.txt
7
+ duppla_slack.egg-info/dependency_links.txt
8
+ duppla_slack.egg-info/requires.txt
9
+ duppla_slack.egg-info/top_level.txt
10
+ duppla_slack/models/__init__.py
11
+ duppla_slack/models/duppla.py
12
+ duppla_slack/models/message.py
13
+ duppla_slack/utils/__init__.py
@@ -0,0 +1,5 @@
1
+ pydantic<3.0.0,>=2.10.0
2
+ requests
3
+ shortuuid
4
+ slack_sdk<4.0.0,>3.30.0
5
+ Unidecode
@@ -0,0 +1 @@
1
+ duppla_slack
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,29 @@
1
+ import setuptools as st
2
+
3
+ # Setting up
4
+ st.setup(
5
+ name="duppla_slack",
6
+ version="2024.12",
7
+ author="duppla",
8
+ author_email="<>",
9
+ description="Custom implementation for Slack API",
10
+ long_description_content_type="text/markdown",
11
+ long_description="A custom implementation for Slack API using Python, based on the official API + SDK.",
12
+ packages=st.find_packages(),
13
+ install_requires=[
14
+ "pydantic>=2.10.0,<3.0.0",
15
+ "requests",
16
+ "shortuuid",
17
+ "slack_sdk>3.30.0,<4.0.0",
18
+ "Unidecode",
19
+ ],
20
+ keywords=["python", "slack", "duppla"],
21
+ classifiers=[
22
+ "Development Status :: 1 - Planning",
23
+ "Intended Audience :: Developers",
24
+ "Programming Language :: Python :: 3",
25
+ "Operating System :: Unix",
26
+ "Operating System :: MacOS :: MacOS X",
27
+ "Operating System :: Microsoft :: Windows",
28
+ ],
29
+ )