telegram_libs 0.1.2__py3-none-any.whl → 0.1.4__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_libs/__init__.py +1 -1
- telegram_libs/constants.py +10 -0
- telegram_libs/translation.py +9 -2
- telegram_libs/utils.py +47 -0
- telegram_libs-0.1.4.dist-info/LICENSE +21 -0
- {telegram_libs-0.1.2.dist-info → telegram_libs-0.1.4.dist-info}/METADATA +4 -1
- telegram_libs-0.1.4.dist-info/RECORD +8 -0
- telegram_libs-0.1.2.dist-info/RECORD +0 -5
- {telegram_libs-0.1.2.dist-info → telegram_libs-0.1.4.dist-info}/WHEEL +0 -0
telegram_libs/__init__.py
CHANGED
@@ -0,0 +1,10 @@
|
|
1
|
+
import os
|
2
|
+
|
3
|
+
required_constants = []
|
4
|
+
|
5
|
+
BOTS_AMOUNT = os.getenv("BOTS_AMOUNT")
|
6
|
+
required_constants.append(("BOTS_AMOUNT", BOTS_AMOUNT))
|
7
|
+
|
8
|
+
missing_constants = [name for name, value in required_constants if not value]
|
9
|
+
if missing_constants:
|
10
|
+
raise ValueError(f"Required constants are not set: {', '.join(missing_constants)}")
|
telegram_libs/translation.py
CHANGED
@@ -1,7 +1,14 @@
|
|
1
1
|
import json
|
2
2
|
import os
|
3
|
+
from typing import Any
|
3
4
|
|
4
|
-
|
5
|
+
|
6
|
+
def load_translations() -> dict:
|
7
|
+
"""Load translations from locales directory
|
8
|
+
|
9
|
+
Returns:
|
10
|
+
dict: Translations dictionary
|
11
|
+
"""
|
5
12
|
translations = {}
|
6
13
|
# Get the project's root directory (where the script is being run from)
|
7
14
|
project_root = os.path.abspath(os.getcwd())
|
@@ -21,7 +28,7 @@ def load_translations():
|
|
21
28
|
|
22
29
|
TRANSLATIONS = load_translations()
|
23
30
|
|
24
|
-
def t(key, lang='ru', **kwargs):
|
31
|
+
def t(key: str, lang: str = 'ru', **kwargs: Any) -> str:
|
25
32
|
"""Get translation for a key with optional formatting"""
|
26
33
|
try:
|
27
34
|
# Support nested keys like "buttons.start"
|
telegram_libs/utils.py
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
from telegram import (
|
2
|
+
InlineKeyboardButton,
|
3
|
+
InlineKeyboardMarkup,
|
4
|
+
)
|
5
|
+
from telegram import Update
|
6
|
+
from telegram.ext import ContextTypes
|
7
|
+
from telegram_libs.constants import BOTS_AMOUNT
|
8
|
+
from telegram_libs.translation import t
|
9
|
+
|
10
|
+
|
11
|
+
async def get_subscription_keyboard(update: Update, lang: str) -> InlineKeyboardMarkup:
|
12
|
+
"""Get subscription keyboard
|
13
|
+
|
14
|
+
Args:
|
15
|
+
update (Update): Update object
|
16
|
+
lang (str): Language code
|
17
|
+
|
18
|
+
Returns:
|
19
|
+
InlineKeyboardMarkup: Inline keyboard markup
|
20
|
+
"""
|
21
|
+
await update.message.reply_text(
|
22
|
+
f"Buying a subscription you will get unlimited access to other {int(BOTS_AMOUNT) - 1} bots, to see all bots click /more"
|
23
|
+
)
|
24
|
+
return [
|
25
|
+
[
|
26
|
+
InlineKeyboardButton(
|
27
|
+
t("subscription.plans.1month", lang), callback_data="sub_1month"
|
28
|
+
),
|
29
|
+
InlineKeyboardButton(
|
30
|
+
t("subscription.plans.3months", lang), callback_data="sub_3months"
|
31
|
+
),
|
32
|
+
],
|
33
|
+
[
|
34
|
+
InlineKeyboardButton(
|
35
|
+
t("subscription.plans.1year", lang), callback_data="sub_1year"
|
36
|
+
),
|
37
|
+
],
|
38
|
+
]
|
39
|
+
|
40
|
+
|
41
|
+
async def more_bots_list_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
42
|
+
message = """Here is the list of all bots: \n\n
|
43
|
+
- <a href="https://t.me/MagMediaBot">Remove Background</a>
|
44
|
+
- <a href="https://t.me/upscale_image_bot">Upscale Image</a>
|
45
|
+
- <a href="https://t.me/kudapoyti_go_bot">Recommend a place to visit</a>
|
46
|
+
"""
|
47
|
+
await update.message.reply_text(message, disable_web_page_preview=True, parse_mode='HTML')
|
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2025 AndreyGritsa
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: telegram_libs
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.4
|
4
4
|
Summary: Common libraries for Telegram bots
|
5
5
|
Author: Andrey Gritsaenko gricaenko.95a@gmail.com
|
6
6
|
Requires-Python: >=3.11,<4.0
|
@@ -9,6 +9,9 @@ Classifier: Programming Language :: Python :: 3.11
|
|
9
9
|
Classifier: Programming Language :: Python :: 3.12
|
10
10
|
Classifier: Programming Language :: Python :: 3.13
|
11
11
|
Requires-Dist: pytest (>=8.3.5,<9.0.0)
|
12
|
+
Requires-Dist: pytest-asyncio (>=1.0.0,<2.0.0)
|
13
|
+
Requires-Dist: python-telegram-bot (>=22.1,<23.0)
|
14
|
+
Project-URL: Repository, https://github.com/AndreyGritsa/telegram_libs
|
12
15
|
Description-Content-Type: text/markdown
|
13
16
|
|
14
17
|
# Telegram Libs
|
@@ -0,0 +1,8 @@
|
|
1
|
+
telegram_libs/__init__.py,sha256=UhMFbEOlA6Z8p2gBV8NxotAQTsstl7Ad9gxb-o66qPY,82
|
2
|
+
telegram_libs/constants.py,sha256=mZC3_2_Favn01sI10VMz9RiQpNpShqdbFfv3aMA3DKg,319
|
3
|
+
telegram_libs/translation.py,sha256=OB89EyvwA89hxDfOJQcod96xoR5FSM4hsexl3_muqq0,1434
|
4
|
+
telegram_libs/utils.py,sha256=S2T6uPyhHJKq9zbcvTGXGUlvW3GetQ9jtA484h_Xqcc,1595
|
5
|
+
telegram_libs-0.1.4.dist-info/LICENSE,sha256=ZXkWPZbCc61L29Gz6ZHPwn1c4Pm0TnfIqtx8jGWi9F4,1069
|
6
|
+
telegram_libs-0.1.4.dist-info/METADATA,sha256=Qg3fWn6RaIamqUkuEj0fnvdYWhzyVv3ap-NrULCX1K4,762
|
7
|
+
telegram_libs-0.1.4.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
|
8
|
+
telegram_libs-0.1.4.dist-info/RECORD,,
|
@@ -1,5 +0,0 @@
|
|
1
|
-
telegram_libs/__init__.py,sha256=F5vFbtaW8HkYEQoTFOdsKSwHMni2vOV17HqtfSKREaY,82
|
2
|
-
telegram_libs/translation.py,sha256=LCJLzKzAfd-65pAvSpW7MFr8o34nsdfWuVWonHI7SQU,1270
|
3
|
-
telegram_libs-0.1.2.dist-info/METADATA,sha256=a4aXMtr0kn5qYO2ITz2PCm4wUMualDySEVfQ9_5Uz5c,594
|
4
|
-
telegram_libs-0.1.2.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
|
5
|
-
telegram_libs-0.1.2.dist-info/RECORD,,
|
File without changes
|