arpakitlib 1.8.142__py3-none-any.whl → 1.8.149__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.
- arpakitlib/_arpakit_project_template_v_5/project/tg_bot_notifier/tg_bot_notifier.py +25 -1
- arpakitlib/_arpakit_project_template_v_5/project/util/send_email_.py +90 -0
- {arpakitlib-1.8.142.dist-info → arpakitlib-1.8.149.dist-info}/METADATA +2 -1
- {arpakitlib-1.8.142.dist-info → arpakitlib-1.8.149.dist-info}/RECORD +7 -6
- {arpakitlib-1.8.142.dist-info → arpakitlib-1.8.149.dist-info}/LICENSE +0 -0
- {arpakitlib-1.8.142.dist-info → arpakitlib-1.8.149.dist-info}/WHEEL +0 -0
- {arpakitlib-1.8.142.dist-info → arpakitlib-1.8.149.dist-info}/entry_points.txt +0 -0
@@ -1,12 +1,14 @@
|
|
1
1
|
import aiogram
|
2
|
+
import telebot
|
2
3
|
from aiogram.client.default import DefaultBotProperties
|
3
4
|
from aiogram.client.session.aiohttp import AiohttpSession
|
4
5
|
from aiogram.enums import ParseMode
|
5
6
|
|
6
7
|
from project.core.settings import get_cached_settings
|
8
|
+
from project.core.util import setup_logging
|
7
9
|
|
8
10
|
|
9
|
-
def
|
11
|
+
def create_async_tg_bot_notifier() -> aiogram.Bot | None:
|
10
12
|
if get_cached_settings().tg_bot_notifier_token is None:
|
11
13
|
return None
|
12
14
|
session: AiohttpSession | None = None
|
@@ -22,3 +24,25 @@ def create_tg_bot_notifier() -> aiogram.Bot | None:
|
|
22
24
|
session=session
|
23
25
|
)
|
24
26
|
return tg_bot
|
27
|
+
|
28
|
+
|
29
|
+
def create_tg_bot_notifier() -> telebot.TeleBot | None:
|
30
|
+
if not get_cached_settings().tg_bot_notifier_token:
|
31
|
+
return None
|
32
|
+
|
33
|
+
if get_cached_settings().tg_bot_notifier_proxy_url is not None:
|
34
|
+
telebot.apihelper.proxy = {
|
35
|
+
"https": get_cached_settings().tg_bot_notifier_proxy_url,
|
36
|
+
"http": get_cached_settings().tg_bot_notifier_proxy_url
|
37
|
+
}
|
38
|
+
|
39
|
+
return telebot.TeleBot(get_cached_settings().tg_bot_notifier_token, parse_mode="HTML")
|
40
|
+
|
41
|
+
|
42
|
+
def __example():
|
43
|
+
setup_logging()
|
44
|
+
create_tg_bot_notifier().send_message(chat_id=269870432, text="Hello world")
|
45
|
+
|
46
|
+
|
47
|
+
if __name__ == '__main__':
|
48
|
+
__example()
|
@@ -0,0 +1,90 @@
|
|
1
|
+
import asyncio
|
2
|
+
import datetime as dt
|
3
|
+
import logging
|
4
|
+
import smtplib
|
5
|
+
from email.message import EmailMessage
|
6
|
+
|
7
|
+
import aiosmtplib
|
8
|
+
|
9
|
+
from project.core.settings import get_cached_settings
|
10
|
+
from project.core.util import setup_logging
|
11
|
+
|
12
|
+
_logger = logging.getLogger(__name__)
|
13
|
+
|
14
|
+
|
15
|
+
def sync_send_email(
|
16
|
+
*,
|
17
|
+
to_email: str,
|
18
|
+
subject: str = "Gamer.Market",
|
19
|
+
html_content: str,
|
20
|
+
emulate: bool = False
|
21
|
+
):
|
22
|
+
to_email = to_email.strip()
|
23
|
+
|
24
|
+
if emulate:
|
25
|
+
_logger.info(f"emulate email sending, {to_email=}, {subject=}, {html_content=}")
|
26
|
+
return
|
27
|
+
|
28
|
+
message = EmailMessage()
|
29
|
+
message["From"] = get_cached_settings().email_smtp_user
|
30
|
+
message["To"] = to_email
|
31
|
+
message["Subject"] = subject
|
32
|
+
message.add_alternative(html_content, subtype="html")
|
33
|
+
|
34
|
+
with smtplib.SMTP_SSL(
|
35
|
+
host=get_cached_settings().email_smtp_hostname,
|
36
|
+
port=get_cached_settings().email_smtp_port,
|
37
|
+
timeout=dt.timedelta(seconds=15).total_seconds()
|
38
|
+
|
39
|
+
) as server:
|
40
|
+
server.login(
|
41
|
+
get_cached_settings().email_smtp_user,
|
42
|
+
get_cached_settings().email_smtp_password
|
43
|
+
)
|
44
|
+
server.send_message(message)
|
45
|
+
|
46
|
+
_logger.info(f"email was send, {to_email=}")
|
47
|
+
|
48
|
+
|
49
|
+
async def async_send_email(
|
50
|
+
*,
|
51
|
+
to_email: str,
|
52
|
+
subject: str = "Gamer.Market",
|
53
|
+
html_content: str,
|
54
|
+
emulate: bool = False
|
55
|
+
):
|
56
|
+
to_email = to_email.strip()
|
57
|
+
|
58
|
+
if emulate:
|
59
|
+
_logger.info(f"emulate email sending, {to_email=}, {subject=}, {html_content=}")
|
60
|
+
return
|
61
|
+
|
62
|
+
message = EmailMessage()
|
63
|
+
message["From"] = get_cached_settings().email_smtp_user
|
64
|
+
message["To"] = to_email
|
65
|
+
message["Subject"] = subject
|
66
|
+
message.add_alternative(html_content, subtype="html")
|
67
|
+
|
68
|
+
await aiosmtplib.send(
|
69
|
+
message,
|
70
|
+
hostname=get_cached_settings().email_smtp_hostname,
|
71
|
+
port=get_cached_settings().email_smtp_port,
|
72
|
+
username=get_cached_settings().email_smtp_user,
|
73
|
+
password=get_cached_settings().email_smtp_password,
|
74
|
+
use_tls=True,
|
75
|
+
timeout=dt.timedelta(seconds=15).total_seconds()
|
76
|
+
)
|
77
|
+
|
78
|
+
_logger.info(f"email was send, {to_email=}")
|
79
|
+
|
80
|
+
|
81
|
+
async def __async_example():
|
82
|
+
setup_logging()
|
83
|
+
await async_send_email(
|
84
|
+
to_email="arpakit@gmail.com",
|
85
|
+
html_content="Hello world 2"
|
86
|
+
)
|
87
|
+
|
88
|
+
|
89
|
+
if __name__ == '__main__':
|
90
|
+
asyncio.run(__async_example())
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: arpakitlib
|
3
|
-
Version: 1.8.
|
3
|
+
Version: 1.8.149
|
4
4
|
Summary: arpakitlib
|
5
5
|
License: Apache-2.0
|
6
6
|
Keywords: arpakitlib,arpakit,arpakit-company,arpakitcompany,arpakit_company
|
@@ -51,6 +51,7 @@ Requires-Dist: pymongo (>=4.10.1,<5.0.0)
|
|
51
51
|
Requires-Dist: pytelegrambotapi (>=4.27.0,<5.0.0)
|
52
52
|
Requires-Dist: pytz (>=2024.2,<2025.0)
|
53
53
|
Requires-Dist: pyzabbix (>=1.3.1,<2.0.0)
|
54
|
+
Requires-Dist: requests-ntlm (>=1.3.0,<2.0.0)
|
54
55
|
Requires-Dist: requests[socks] (>=2.32.3,<3.0.0)
|
55
56
|
Requires-Dist: scipy (>=1.15.1,<2.0.0)
|
56
57
|
Requires-Dist: speechrecognition (>=3.14.3,<4.0.0)
|
@@ -353,10 +353,11 @@ arpakitlib/_arpakit_project_template_v_5/project/tg_bot/util/notify_admins.py,sh
|
|
353
353
|
arpakitlib/_arpakit_project_template_v_5/project/tg_bot/util/set_tg_bot_commands.py,sha256=eTVOpwp8zn74QhLgmbLkxn3cH4xPzQN02euS-7UP-Eg,3489
|
354
354
|
arpakitlib/_arpakit_project_template_v_5/project/tg_bot_notifier/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
355
355
|
arpakitlib/_arpakit_project_template_v_5/project/tg_bot_notifier/blank.py,sha256=0rspOC-xS9qdQ58pAJI-tNTgbylQIXCrEr79MMgvU1k,406
|
356
|
-
arpakitlib/_arpakit_project_template_v_5/project/tg_bot_notifier/tg_bot_notifier.py,sha256=
|
356
|
+
arpakitlib/_arpakit_project_template_v_5/project/tg_bot_notifier/tg_bot_notifier.py,sha256=QMVOgvW4xJvi46vsdpw27IDrmI76W_Go_GJFUCvHfAc,1552
|
357
357
|
arpakitlib/_arpakit_project_template_v_5/project/util/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
358
358
|
arpakitlib/_arpakit_project_template_v_5/project/util/arpakitlib_project_template_util.py,sha256=syA_IuszHVub0zm0sVdB4_7rPJXwXRW4JmQ4qHbjXPk,396
|
359
359
|
arpakitlib/_arpakit_project_template_v_5/project/util/etc.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
360
|
+
arpakitlib/_arpakit_project_template_v_5/project/util/send_email_.py,sha256=ehpBiIt6vpUXeuIY_tvr-80LGM7VBCUhgASGZpWy-Ok,2387
|
360
361
|
arpakitlib/_arpakit_project_template_v_5/todo.txt,sha256=q132Jbx229ThY77S3YiN-Cj5AVm7k1VlJcMYIbZUHUY,3
|
361
362
|
arpakitlib/ar_additional_model_util.py,sha256=GFg-glLCxH9X95R2bhTJsscVwv37FgE1qbaAAyXrnIE,917
|
362
363
|
arpakitlib/ar_aiogram_util.py,sha256=4bizX5Xg-E2-r2TXXGQGanJozsIWPVf5luO3vKUN8p8,8471
|
@@ -405,8 +406,8 @@ arpakitlib/ar_ssh_runner_util.py,sha256=yvAwza480MkHKvLkDEsR7JNh2bYNs6P9rCVo4NA8
|
|
405
406
|
arpakitlib/ar_str_util.py,sha256=2lGpnXDf2h1cBZpVf5i1tX_HCv5iBd6IGnrCw4QWWlY,4350
|
406
407
|
arpakitlib/ar_type_util.py,sha256=Cs_tef-Fc5xeyAF54KgISCsP11NHyzIsglm4S3Xx7iM,4049
|
407
408
|
arpakitlib/ar_yookassa_api_client_util.py,sha256=VozuZeCJjmLd1zj2BdC9WfiAQ3XYOrIMsdpNK-AUlm0,5347
|
408
|
-
arpakitlib-1.8.
|
409
|
-
arpakitlib-1.8.
|
410
|
-
arpakitlib-1.8.
|
411
|
-
arpakitlib-1.8.
|
412
|
-
arpakitlib-1.8.
|
409
|
+
arpakitlib-1.8.149.dist-info/LICENSE,sha256=GPEDQMam2r7FSTYqM1mm7aKnxLaWcBotH7UvQtea-ec,11355
|
410
|
+
arpakitlib-1.8.149.dist-info/METADATA,sha256=6PCWAbE5oRC_-nHI_hKCKx1NDT8snzoGyx_5eoEYfhE,3706
|
411
|
+
arpakitlib-1.8.149.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
412
|
+
arpakitlib-1.8.149.dist-info/entry_points.txt,sha256=36xqR3PJFT2kuwjkM_EqoIy0qFUDPKSm_mJaI7emewE,87
|
413
|
+
arpakitlib-1.8.149.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|