apache-airflow-providers-telegram 4.6.0__tar.gz → 4.7.0__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.
@@ -1,11 +1,11 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.3
2
2
  Name: apache-airflow-providers-telegram
3
- Version: 4.6.0
3
+ Version: 4.7.0
4
4
  Summary: Provider package apache-airflow-providers-telegram for Apache Airflow
5
5
  Keywords: airflow-provider,telegram,airflow,integration
6
6
  Author-email: Apache Software Foundation <dev@airflow.apache.org>
7
7
  Maintainer-email: Apache Software Foundation <dev@airflow.apache.org>
8
- Requires-Python: ~=3.8
8
+ Requires-Python: ~=3.9
9
9
  Description-Content-Type: text/x-rst
10
10
  Classifier: Development Status :: 5 - Production/Stable
11
11
  Classifier: Environment :: Console
@@ -15,20 +15,19 @@ Classifier: Intended Audience :: System Administrators
15
15
  Classifier: Framework :: Apache Airflow
16
16
  Classifier: Framework :: Apache Airflow :: Provider
17
17
  Classifier: License :: OSI Approved :: Apache Software License
18
- Classifier: Programming Language :: Python :: 3.8
19
18
  Classifier: Programming Language :: Python :: 3.9
20
19
  Classifier: Programming Language :: Python :: 3.10
21
20
  Classifier: Programming Language :: Python :: 3.11
22
21
  Classifier: Programming Language :: Python :: 3.12
23
22
  Classifier: Topic :: System :: Monitoring
24
- Requires-Dist: apache-airflow>=2.8.0
23
+ Requires-Dist: apache-airflow>=2.9.0
25
24
  Requires-Dist: python-telegram-bot>=20.2
26
25
  Project-URL: Bug Tracker, https://github.com/apache/airflow/issues
27
- Project-URL: Changelog, https://airflow.apache.org/docs/apache-airflow-providers-telegram/4.6.0/changelog.html
28
- Project-URL: Documentation, https://airflow.apache.org/docs/apache-airflow-providers-telegram/4.6.0
26
+ Project-URL: Changelog, https://airflow.apache.org/docs/apache-airflow-providers-telegram/4.7.0/changelog.html
27
+ Project-URL: Documentation, https://airflow.apache.org/docs/apache-airflow-providers-telegram/4.7.0
29
28
  Project-URL: Slack Chat, https://s.apache.org/airflow-slack
30
29
  Project-URL: Source Code, https://github.com/apache/airflow
31
- Project-URL: Twitter, https://twitter.com/ApacheAirflow
30
+ Project-URL: Twitter, https://x.com/ApacheAirflow
32
31
  Project-URL: YouTube, https://www.youtube.com/channel/UCSXwxpWZQ7XZ1WL3wqevChA/
33
32
 
34
33
 
@@ -75,7 +74,7 @@ Project-URL: YouTube, https://www.youtube.com/channel/UCSXwxpWZQ7XZ1WL3wqevChA/
75
74
 
76
75
  Package ``apache-airflow-providers-telegram``
77
76
 
78
- Release: ``4.6.0``
77
+ Release: ``4.7.0``
79
78
 
80
79
 
81
80
  `Telegram <https://telegram.org/>`__
@@ -88,7 +87,7 @@ This is a provider package for ``telegram`` provider. All classes for this provi
88
87
  are in ``airflow.providers.telegram`` python package.
89
88
 
90
89
  You can find package information and changelog for the provider
91
- in the `documentation <https://airflow.apache.org/docs/apache-airflow-providers-telegram/4.6.0/>`_.
90
+ in the `documentation <https://airflow.apache.org/docs/apache-airflow-providers-telegram/4.7.0/>`_.
92
91
 
93
92
  Installation
94
93
  ------------
@@ -97,7 +96,7 @@ You can install this package on top of an existing Airflow 2 installation (see `
97
96
  for the minimum Airflow version supported) via
98
97
  ``pip install apache-airflow-providers-telegram``
99
98
 
100
- The package supports the following python versions: 3.8,3.9,3.10,3.11,3.12
99
+ The package supports the following python versions: 3.9,3.10,3.11,3.12
101
100
 
102
101
  Requirements
103
102
  ------------
@@ -105,9 +104,9 @@ Requirements
105
104
  ======================= ==================
106
105
  PIP package Version required
107
106
  ======================= ==================
108
- ``apache-airflow`` ``>=2.8.0``
107
+ ``apache-airflow`` ``>=2.9.0``
109
108
  ``python-telegram-bot`` ``>=20.2``
110
109
  ======================= ==================
111
110
 
112
111
  The changelog for the provider package can be found in the
113
- `changelog <https://airflow.apache.org/docs/apache-airflow-providers-telegram/4.6.0/changelog.html>`_.
112
+ `changelog <https://airflow.apache.org/docs/apache-airflow-providers-telegram/4.7.0/changelog.html>`_.
@@ -42,7 +42,7 @@
42
42
 
43
43
  Package ``apache-airflow-providers-telegram``
44
44
 
45
- Release: ``4.6.0``
45
+ Release: ``4.7.0``
46
46
 
47
47
 
48
48
  `Telegram <https://telegram.org/>`__
@@ -55,7 +55,7 @@ This is a provider package for ``telegram`` provider. All classes for this provi
55
55
  are in ``airflow.providers.telegram`` python package.
56
56
 
57
57
  You can find package information and changelog for the provider
58
- in the `documentation <https://airflow.apache.org/docs/apache-airflow-providers-telegram/4.6.0/>`_.
58
+ in the `documentation <https://airflow.apache.org/docs/apache-airflow-providers-telegram/4.7.0/>`_.
59
59
 
60
60
  Installation
61
61
  ------------
@@ -64,7 +64,7 @@ You can install this package on top of an existing Airflow 2 installation (see `
64
64
  for the minimum Airflow version supported) via
65
65
  ``pip install apache-airflow-providers-telegram``
66
66
 
67
- The package supports the following python versions: 3.8,3.9,3.10,3.11,3.12
67
+ The package supports the following python versions: 3.9,3.10,3.11,3.12
68
68
 
69
69
  Requirements
70
70
  ------------
@@ -72,9 +72,9 @@ Requirements
72
72
  ======================= ==================
73
73
  PIP package Version required
74
74
  ======================= ==================
75
- ``apache-airflow`` ``>=2.8.0``
75
+ ``apache-airflow`` ``>=2.9.0``
76
76
  ``python-telegram-bot`` ``>=20.2``
77
77
  ======================= ==================
78
78
 
79
79
  The changelog for the provider package can be found in the
80
- `changelog <https://airflow.apache.org/docs/apache-airflow-providers-telegram/4.6.0/changelog.html>`_.
80
+ `changelog <https://airflow.apache.org/docs/apache-airflow-providers-telegram/4.7.0/changelog.html>`_.
@@ -29,11 +29,11 @@ from airflow import __version__ as airflow_version
29
29
 
30
30
  __all__ = ["__version__"]
31
31
 
32
- __version__ = "4.6.0"
32
+ __version__ = "4.7.0"
33
33
 
34
34
  if packaging.version.parse(packaging.version.parse(airflow_version).base_version) < packaging.version.parse(
35
- "2.8.0"
35
+ "2.9.0"
36
36
  ):
37
37
  raise RuntimeError(
38
- f"The package `apache-airflow-providers-telegram:{__version__}` needs Apache Airflow 2.8.0+"
38
+ f"The package `apache-airflow-providers-telegram:{__version__}` needs Apache Airflow 2.9.0+"
39
39
  )
@@ -28,8 +28,9 @@ def get_provider_info():
28
28
  "name": "Telegram",
29
29
  "description": "`Telegram <https://telegram.org/>`__\n",
30
30
  "state": "ready",
31
- "source-date-epoch": 1723970613,
31
+ "source-date-epoch": 1734537315,
32
32
  "versions": [
33
+ "4.7.0",
33
34
  "4.6.0",
34
35
  "4.5.2",
35
36
  "4.5.1",
@@ -53,7 +54,7 @@ def get_provider_info():
53
54
  "1.0.1",
54
55
  "1.0.0",
55
56
  ],
56
- "dependencies": ["apache-airflow>=2.8.0", "python-telegram-bot>=20.2"],
57
+ "dependencies": ["apache-airflow>=2.9.0", "python-telegram-bot>=20.2"],
57
58
  "integrations": [
58
59
  {
59
60
  "integration-name": "Telegram",
@@ -158,3 +158,33 @@ class TelegramHook(BaseHook):
158
158
 
159
159
  response = asyncio.run(self.connection.send_message(**kwargs))
160
160
  self.log.debug(response)
161
+
162
+ @tenacity.retry(
163
+ retry=tenacity.retry_if_exception_type(telegram.error.TelegramError),
164
+ stop=tenacity.stop_after_attempt(5),
165
+ wait=tenacity.wait_fixed(1),
166
+ )
167
+ def send_file(self, api_params: dict) -> None:
168
+ """
169
+ Send the file to a telegram channel or chat.
170
+
171
+ :param api_params: params for telegram_instance.send_document. It can also be used to override chat_id
172
+ """
173
+ kwargs: dict[str, Any] = {}
174
+
175
+ if self.chat_id is not None:
176
+ kwargs["chat_id"] = self.chat_id
177
+ kwargs.update(api_params)
178
+
179
+ if "file" not in kwargs or kwargs["file"] is None:
180
+ raise AirflowException(
181
+ "'file' parameter must be provided for sending a Telegram document message"
182
+ )
183
+
184
+ kwargs["document"] = kwargs.pop("file") # rename 'file' to 'document'
185
+
186
+ if kwargs.get("chat_id") is None:
187
+ raise AirflowException("'chat_id' must be provided for telegram document message")
188
+
189
+ response = asyncio.run(self.connection.send_document(**kwargs))
190
+ self.log.debug(response)
@@ -19,7 +19,8 @@
19
19
 
20
20
  from __future__ import annotations
21
21
 
22
- from typing import TYPE_CHECKING, Sequence
22
+ from collections.abc import Sequence
23
+ from typing import TYPE_CHECKING
23
24
 
24
25
  from airflow.exceptions import AirflowException
25
26
  from airflow.models import BaseOperator
@@ -83,3 +84,59 @@ class TelegramOperator(BaseOperator):
83
84
  chat_id=self.chat_id,
84
85
  )
85
86
  telegram_hook.send_message(self.telegram_kwargs)
87
+
88
+
89
+ class TelegramFileOperator(BaseOperator):
90
+ """
91
+ This operator allows you to send file to Telegram using Telegram Bot API.
92
+
93
+ Takes both Telegram Bot API token directly or connection that has Telegram token in password field.
94
+ If both supplied, token parameter will be given precedence.
95
+
96
+ .. seealso::
97
+ For more information on how to use this operator, take a look at the guide:
98
+ :ref:`howto/operator:TelegramOperator`
99
+
100
+ :param telegram_conn_id: Telegram connection ID which its password is Telegram API token
101
+ :param token: Telegram API Token
102
+ :param chat_id: Telegram chat ID for a chat/channel/group
103
+ :param file: The path of the file or media to be sent via Telegram
104
+ :param telegram_kwargs: Extra args to be passed to telegram client
105
+ """
106
+
107
+ template_fields: Sequence[str] = "chat_id"
108
+ ui_color = "#FFBA40"
109
+
110
+ def __init__(
111
+ self,
112
+ *,
113
+ telegram_conn_id: str = "telegram_default",
114
+ token: str | None = None,
115
+ chat_id: str | None = None,
116
+ file: str,
117
+ telegram_kwargs: dict | None = None,
118
+ **kwargs,
119
+ ):
120
+ self.chat_id = chat_id
121
+ self.token = token
122
+ self.telegram_kwargs = telegram_kwargs or {}
123
+ self.file = file
124
+
125
+ if telegram_conn_id is None:
126
+ raise AirflowException("No valid Telegram connection id supplied.")
127
+
128
+ self.telegram_conn_id = telegram_conn_id
129
+
130
+ super().__init__(**kwargs)
131
+
132
+ def execute(self, context: Context) -> None:
133
+ """Call the TelegramHook to send the provided Telegram file."""
134
+ if self.file:
135
+ self.telegram_kwargs["file"] = self.file
136
+
137
+ telegram_hook = TelegramHook(
138
+ telegram_conn_id=self.telegram_conn_id,
139
+ token=self.token,
140
+ chat_id=self.chat_id,
141
+ )
142
+ telegram_hook.send_file(**self.telegram_kwargs)
@@ -21,14 +21,13 @@
21
21
 
22
22
  # IF YOU WANT TO MODIFY THIS FILE, YOU SHOULD MODIFY THE TEMPLATE
23
23
  # `pyproject_TEMPLATE.toml.jinja2` IN the `dev/breeze/src/airflow_breeze/templates` DIRECTORY
24
- #
25
24
  [build-system]
26
- requires = ["flit_core >=3.2,<4"]
25
+ requires = ["flit_core==3.10.1"]
27
26
  build-backend = "flit_core.buildapi"
28
27
 
29
28
  [project]
30
29
  name = "apache-airflow-providers-telegram"
31
- version = "4.6.0"
30
+ version = "4.7.0"
32
31
  description = "Provider package apache-airflow-providers-telegram for Apache Airflow"
33
32
  readme = "README.rst"
34
33
  authors = [
@@ -47,26 +46,25 @@ classifiers = [
47
46
  "Framework :: Apache Airflow",
48
47
  "Framework :: Apache Airflow :: Provider",
49
48
  "License :: OSI Approved :: Apache Software License",
50
- "Programming Language :: Python :: 3.8",
51
49
  "Programming Language :: Python :: 3.9",
52
50
  "Programming Language :: Python :: 3.10",
53
51
  "Programming Language :: Python :: 3.11",
54
52
  "Programming Language :: Python :: 3.12",
55
53
  "Topic :: System :: Monitoring",
56
54
  ]
57
- requires-python = "~=3.8"
55
+ requires-python = "~=3.9"
58
56
  dependencies = [
59
- "apache-airflow>=2.8.0",
57
+ "apache-airflow>=2.9.0",
60
58
  "python-telegram-bot>=20.2",
61
59
  ]
62
60
 
63
61
  [project.urls]
64
- "Documentation" = "https://airflow.apache.org/docs/apache-airflow-providers-telegram/4.6.0"
65
- "Changelog" = "https://airflow.apache.org/docs/apache-airflow-providers-telegram/4.6.0/changelog.html"
62
+ "Documentation" = "https://airflow.apache.org/docs/apache-airflow-providers-telegram/4.7.0"
63
+ "Changelog" = "https://airflow.apache.org/docs/apache-airflow-providers-telegram/4.7.0/changelog.html"
66
64
  "Bug Tracker" = "https://github.com/apache/airflow/issues"
67
65
  "Source Code" = "https://github.com/apache/airflow"
68
66
  "Slack Chat" = "https://s.apache.org/airflow-slack"
69
- "Twitter" = "https://twitter.com/ApacheAirflow"
67
+ "Twitter" = "https://x.com/ApacheAirflow"
70
68
  "YouTube" = "https://www.youtube.com/channel/UCSXwxpWZQ7XZ1WL3wqevChA/"
71
69
 
72
70
  [project.entry-points."apache_airflow_provider"]