telegram-python 0.3.0__py3-none-any.whl → 0.3.1__py3-none-any.whl
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.
- telegram_python/README.md +0 -0
- telegram_python/pyproject.toml +14 -0
- telegram_python/telegram_python/__init__.py +0 -0
- telegram_python/tests/__init__.py +0 -0
- telegram_python-0.3.1.dist-info/METADATA +20 -0
- telegram_python-0.3.1.dist-info/RECORD +7 -0
- {telegram_python-0.3.0.dist-info → telegram_python-0.3.1.dist-info}/WHEEL +1 -2
- telegram_python-0.3.0.dist-info/METADATA +0 -11
- telegram_python-0.3.0.dist-info/RECORD +0 -6
- telegram_python-0.3.0.dist-info/top_level.txt +0 -1
- telegram_send/__init__.py +0 -2
- telegram_send/telegram_send.py +0 -44
|
File without changes
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
[tool.poetry]
|
|
2
|
+
name = "telegram-python"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = ""
|
|
5
|
+
authors = ["Tatiana <durachevska@ukr.net>"]
|
|
6
|
+
readme = "README.md"
|
|
7
|
+
|
|
8
|
+
[tool.poetry.dependencies]
|
|
9
|
+
python = "^3.11"
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
[build-system]
|
|
13
|
+
requires = ["poetry-core"]
|
|
14
|
+
build-backend = "poetry.core.masonry.api"
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: telegram-python
|
|
3
|
+
Version: 0.3.1
|
|
4
|
+
Summary: A Python package for sending Telegram messages
|
|
5
|
+
Author: Tatiana
|
|
6
|
+
Author-email: durachevska@ukr.net
|
|
7
|
+
Requires-Python: >=3.10,<4.0
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
13
|
+
Requires-Dist: requests (>=2.32.3,<3.0.0)
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
|
|
16
|
+
poetry add telegram_send
|
|
17
|
+
|
|
18
|
+
cd demo
|
|
19
|
+
poe demo
|
|
20
|
+
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
telegram_python/pyproject.toml,sha256=TxGFlPrii_Aop4pfmtq1yXMzNzhegdYAEB1n7ELxz9A,284
|
|
2
|
+
telegram_python/README.md,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
+
telegram_python/telegram_python/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
+
telegram_python/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
|
+
telegram_python-0.3.1.dist-info/METADATA,sha256=j7phmmP41I2uAWtULw8LctDs5YsT8mATOqam8TqPHTo,573
|
|
6
|
+
telegram_python-0.3.1.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
|
7
|
+
telegram_python-0.3.1.dist-info/RECORD,,
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: telegram-python
|
|
3
|
-
Version: 0.3.0
|
|
4
|
-
Summary: A Python package for sending Telegram messages
|
|
5
|
-
Author: Tetiana
|
|
6
|
-
Author-email: Tatiana <durachevska@ukr.net>
|
|
7
|
-
Description-Content-Type: text/markdown
|
|
8
|
-
|
|
9
|
-
poetry add telegram_send
|
|
10
|
-
|
|
11
|
-
poetry run python demo/demo.py
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
telegram_send/__init__.py,sha256=imyb6s9X7XSCuwhyYSTAwWUctgtdiO3GzWBzNKacJDI,158
|
|
2
|
-
telegram_send/telegram_send.py,sha256=a33Jf5aROlZXZzkiDhn2MlAJtRkReLbCQFRePs1RXCI,1755
|
|
3
|
-
telegram_python-0.3.0.dist-info/METADATA,sha256=OAT82CxyuXVWLO7NDDjR9yWquwB-5pCZcrmiRt8GL-E,284
|
|
4
|
-
telegram_python-0.3.0.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
|
|
5
|
-
telegram_python-0.3.0.dist-info/top_level.txt,sha256=p1caPsfF4vqshvK4zD3ZoFUjy9TbzrLwuIUFSMgnEGs,14
|
|
6
|
-
telegram_python-0.3.0.dist-info/RECORD,,
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
telegram_send
|
telegram_send/__init__.py
DELETED
telegram_send/telegram_send.py
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import requests
|
|
2
|
-
from datetime import datetime
|
|
3
|
-
import os
|
|
4
|
-
import logging
|
|
5
|
-
|
|
6
|
-
start_hour = int(os.getenv("TELEGRAM_START_HOUR", 0))
|
|
7
|
-
end_hour = int(os.getenv("TELEGRAM_END_HOUR", 24))
|
|
8
|
-
bot_token = os.getenv("TELEGRAM_BOT_TOKEN")
|
|
9
|
-
chat_id = os.getenv("TELEGRAM_CHAT_ID")
|
|
10
|
-
|
|
11
|
-
logging.basicConfig(level=logging.INFO, filename="py_log.log",filemode="w",
|
|
12
|
-
format="%(asctime)s %(levelname)s %(message)s")
|
|
13
|
-
|
|
14
|
-
def send(message: str) -> None:
|
|
15
|
-
"""
|
|
16
|
-
Відправляє повідомлення в Telegram в заданий час (від 0 до 24).
|
|
17
|
-
"""
|
|
18
|
-
now = datetime.now()
|
|
19
|
-
current_hour = now.hour
|
|
20
|
-
telegram_max_symbol = 4096
|
|
21
|
-
if start_hour <= current_hour and current_hour < end_hour:
|
|
22
|
-
try:
|
|
23
|
-
if len(message) > telegram_max_symbol:
|
|
24
|
-
message = message[:telegram_max_symbol]
|
|
25
|
-
|
|
26
|
-
url = f"https://api.telegram.org/bot{bot_token}/sendMessage"
|
|
27
|
-
payload = {
|
|
28
|
-
"chat_id": chat_id,
|
|
29
|
-
"text": message
|
|
30
|
-
}
|
|
31
|
-
my_rez=requests.post(url, json=payload, timeout=10)
|
|
32
|
-
print(my_rez)
|
|
33
|
-
|
|
34
|
-
if my_rez.status_code == 200:
|
|
35
|
-
logging.info(f"Message sent successfully to chat_id={chat_id}")
|
|
36
|
-
else:
|
|
37
|
-
logging.error(f"Message sent with reason: {my_rez.reason}")
|
|
38
|
-
|
|
39
|
-
except requests.exceptions.RequestException as e:
|
|
40
|
-
logging.error(f"Error sending message: {e}") # помилки, пов’язані з HTTP-запитами
|
|
41
|
-
except Exception as e:
|
|
42
|
-
logging.error(f"Unexpected error: {e}")
|
|
43
|
-
else:
|
|
44
|
-
logging.info(f"Current time ({current_hour}) is outside the allowed range ({start_hour}-{end_hour}).")
|