telegram_libs 0.1.8__py3-none-any.whl → 0.1.10__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 CHANGED
@@ -2,4 +2,4 @@
2
2
  Telegram Libs - Common libraries for Telegram bots
3
3
  """
4
4
 
5
- __version__ = "0.1.8"
5
+ __version__ = "0.1.10"
@@ -2,9 +2,18 @@
2
2
  "subscription": {
3
3
  "choose_plan": "Choose a subscription plan:",
4
4
  "plans": {
5
- "1month": "1 Month - 250 Stars",
6
- "3months": "3 Months - 500 Stars",
7
- "1year": "1 Year - 1600 Stars"
8
- }
5
+ "1month": "1 Month - 1400 Stars",
6
+ "3months": "3 Months - 3500 Stars",
7
+ "1year": "1 Year - 12000 Stars"
8
+ },
9
+ "info": "Buying a subscription you will get unlimited access to other {0} bots, to see all bots click /more"
10
+ },
11
+ "support": {
12
+ "message": "If you have any questions or need help, please contact our support team at @support_channel.",
13
+ "response": "Thank you! Our support team will contact you soon."
14
+ },
15
+ "feedback": {
16
+ "message": "We appreciate your feedback! Please send your suggestions or issues and we will review them as soon as possible.",
17
+ "response": "Thank you for your feedback!"
9
18
  }
10
19
  }
@@ -2,9 +2,18 @@
2
2
  "subscription": {
3
3
  "choose_plan": "Выберите план подписки:",
4
4
  "plans": {
5
- "1month": "1 месяц - 250 Stars",
6
- "3months": "3 месяца - 500 Stars",
7
- "1year": "1 год - 1600 Stars"
8
- }
5
+ "1month": "1 месяц - 1400 Stars",
6
+ "3months": "3 месяца - 3500 Stars",
7
+ "1year": "1 год - 12000 Stars"
8
+ },
9
+ "info": "Купив подписку, вы получите неограниченный доступ к другим {0} ботам, чтобы увидеть всех ботов, нажмите /more"
10
+ },
11
+ "support": {
12
+ "message": "Если у вас есть вопросы или нужна помощь, пожалуйста, свяжитесь с нашей службой поддержки @support_channel.",
13
+ "response": "Спасибо! Наша служба поддержки свяжется с вами в ближайшее время."
14
+ },
15
+ "feedback": {
16
+ "message": "Мы ценим ваш отзыв! Пожалуйста, присылайте ваши предложения или проблемы, и мы рассмотрим их как можно скорее.",
17
+ "response": "Спасибо за ваш отзыв!"
9
18
  }
10
19
  }
telegram_libs/mongo.py ADDED
@@ -0,0 +1,6 @@
1
+ from pymongo.mongo_client import MongoClient
2
+ from pymongo.server_api import ServerApi
3
+ from telegram_libs.constants import MONGO_URI
4
+
5
+ # Create a new client and connect to the server
6
+ mongo_client = MongoClient(MONGO_URI, server_api=ServerApi("1"))
@@ -1,13 +1,9 @@
1
1
  from datetime import datetime
2
- from pymongo.mongo_client import MongoClient
3
- from pymongo.server_api import ServerApi
4
- from telegram_libs.constants import MONGO_URI, SUBSCRIPTION_DB_NAME
5
-
6
- # Create a new client and connect to the server
7
- client = MongoClient(MONGO_URI, server_api=ServerApi("1"))
2
+ from telegram_libs.constants import SUBSCRIPTION_DB_NAME
3
+ from telegram_libs.mongo import mongo_client
8
4
 
9
5
  # Define the subscription database and collection
10
- subscription_db = client[SUBSCRIPTION_DB_NAME]
6
+ subscription_db = mongo_client[SUBSCRIPTION_DB_NAME]
11
7
  subscription_collection = subscription_db["subscriptions"]
12
8
 
13
9
 
telegram_libs/utils.py CHANGED
@@ -3,9 +3,14 @@ from telegram import (
3
3
  InlineKeyboardMarkup,
4
4
  )
5
5
  from telegram import Update
6
- from telegram.ext import ContextTypes
6
+ from telegram.ext import ContextTypes, Application, CommandHandler, MessageHandler, filters
7
7
  from telegram_libs.constants import BOTS_AMOUNT
8
8
  from telegram_libs.translation import t
9
+ from telegram_libs.mongo import mongo_client
10
+ from functools import partial
11
+
12
+ FEEDBACK_WAITING = "feedback_waiting"
13
+ SUPPORT_WAITING = "support_waiting"
9
14
 
10
15
 
11
16
  async def get_subscription_keyboard(update: Update, lang: str) -> InlineKeyboardMarkup:
@@ -19,7 +24,7 @@ async def get_subscription_keyboard(update: Update, lang: str) -> InlineKeyboard
19
24
  InlineKeyboardMarkup: Inline keyboard markup
20
25
  """
21
26
  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"
27
+ t("subscription.info", lang, common=True).format(int(BOTS_AMOUNT) - 1)
23
28
  )
24
29
  return [
25
30
  [
@@ -46,4 +51,66 @@ async def more_bots_list_command(update: Update, context: ContextTypes.DEFAULT_T
46
51
  - <a href="https://t.me/kudapoyti_go_bot">Recommend a place to visit</a>
47
52
  - <a href="https://t.me/TryOnOutfitGBot">Try On Outfit</a>
48
53
  """
49
- await update.message.reply_text(message, disable_web_page_preview=True, parse_mode='HTML')
54
+ await update.message.reply_text(message, disable_web_page_preview=True, parse_mode='HTML')
55
+
56
+
57
+ async def support_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
58
+ """Support command handler"""
59
+ await update.message.reply_text(
60
+ t("support.message", update.effective_user.language_code, common=True)
61
+ )
62
+ context.user_data[SUPPORT_WAITING] = True
63
+
64
+
65
+ async def handle_support_response(update: Update, context: ContextTypes.DEFAULT_TYPE, bot_name: str) -> None:
66
+ """Handle user's support message"""
67
+ if context.user_data.get(SUPPORT_WAITING):
68
+ support_db = mongo_client["support"]
69
+ support_collection = support_db["support"]
70
+ support_doc = {
71
+ "user_id": update.effective_user.id,
72
+ "username": update.effective_user.username,
73
+ "message": update.message.text,
74
+ "bot_name": bot_name,
75
+ }
76
+ support_collection.insert_one(support_doc)
77
+ await update.message.reply_text(t("support.response", update.effective_user.language_code, common=True))
78
+ context.user_data[SUPPORT_WAITING] = False
79
+
80
+
81
+ async def feedback_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
82
+ """Feedback command handler"""
83
+ await update.message.reply_text(
84
+ t("feedback.message", update.effective_user.language_code, common=True)
85
+ )
86
+ context.user_data[FEEDBACK_WAITING] = True
87
+
88
+
89
+ async def handle_feedback_response(update: Update, context: ContextTypes.DEFAULT_TYPE, bot_name: str) -> None:
90
+ """Handle user's feedback message"""
91
+ if context.user_data.get(FEEDBACK_WAITING):
92
+ feedback_db = mongo_client["feedback"]
93
+ feedback_collection = feedback_db["feedback"]
94
+ feedback_doc = {
95
+ "user_id": update.effective_user.id,
96
+ "username": update.effective_user.username,
97
+ "feedback": update.message.text,
98
+ "bot_name": bot_name,
99
+ }
100
+ feedback_collection.insert_one(feedback_doc)
101
+ await update.message.reply_text(t("feedback.response", update.effective_user.language_code, common=True))
102
+ context.user_data[FEEDBACK_WAITING] = False
103
+
104
+
105
+ def register_feedback_and_support_handlers(app: Application, bot_name: str) -> None:
106
+ """Register feedback and support handlers for the bot"""
107
+ app.add_handler(CommandHandler("feedback", feedback_command))
108
+ app.add_handler(MessageHandler(filters.TEXT & ~filters.COMMAND, partial(handle_feedback_response, bot_name=bot_name)))
109
+ app.add_handler(CommandHandler("support", support_command))
110
+ app.add_handler(MessageHandler(filters.TEXT & ~filters.COMMAND, partial(handle_support_response, bot_name=bot_name)))
111
+
112
+
113
+ def register_common_handlers(app: Application, bot_name: str) -> None:
114
+ """Register common handlers for the bot"""
115
+ app.add_handler(CommandHandler("more", more_bots_list_command))
116
+ register_feedback_and_support_handlers(app, bot_name)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: telegram_libs
3
- Version: 0.1.8
3
+ Version: 0.1.10
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
@@ -0,0 +1,12 @@
1
+ telegram_libs/__init__.py,sha256=zJ7P4cSnN9eH2I7zKDtM50HAH0CKHfanZjIjnVeJfZA,82
2
+ telegram_libs/constants.py,sha256=F6pgwAuv2FgGZxxFwYYJomM4_hosexLoYsvHXQiuVNg,538
3
+ telegram_libs/locales/en.json,sha256=l9BAvVgBkvKH_kRiAb9md5Ls0Riv9kfGyXEGca6cOk4,732
4
+ telegram_libs/locales/ru.json,sha256=YwxuBb-OeQKqjASCkNqK_Kr2V_wRGrrnEqHXaUMawso,1111
5
+ telegram_libs/mongo.py,sha256=7UOy_cE0ofIbH7QiiirAjOgo_FM9JImtgxQ8ouEsFeo,245
6
+ telegram_libs/subscription.py,sha256=d7xmzplUrm1nNlWlkqW6dddOYa3t_7PAM3iPme0K5F0,1690
7
+ telegram_libs/translation.py,sha256=8Kb2cgqKKZH4X_i2Le0V_K1imZdoaCzYAca831DOBig,2049
8
+ telegram_libs/utils.py,sha256=JPntJwEMsUrg1q2AFBBK82o8YAFaewXq652qv7FmWWI,4784
9
+ telegram_libs-0.1.10.dist-info/LICENSE,sha256=ZXkWPZbCc61L29Gz6ZHPwn1c4Pm0TnfIqtx8jGWi9F4,1069
10
+ telegram_libs-0.1.10.dist-info/METADATA,sha256=AqsjI-HerHwu_7lapgZpuki8AivpvXWPedRWHPmMXcc,804
11
+ telegram_libs-0.1.10.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
12
+ telegram_libs-0.1.10.dist-info/RECORD,,
@@ -1,11 +0,0 @@
1
- telegram_libs/__init__.py,sha256=pfzXFiRuI-tM8xQ0Zd20JiAklZNMP2P0Jp2q3-ymMEE,81
2
- telegram_libs/constants.py,sha256=F6pgwAuv2FgGZxxFwYYJomM4_hosexLoYsvHXQiuVNg,538
3
- telegram_libs/locales/en.json,sha256=KBSPceLmnXofYombDIsF9tMQ_slidi6BGZ_64MYVI1A,216
4
- telegram_libs/locales/ru.json,sha256=xM_6OFya8jRpQoNepwUjNXvTa_voNkqHkqZc-oSl8-Y,245
5
- telegram_libs/subscription.py,sha256=qUFo8QLOUoAZFvlQM1lWojpKwVwzhLvWPeyk45nP2sg,1844
6
- telegram_libs/translation.py,sha256=8Kb2cgqKKZH4X_i2Le0V_K1imZdoaCzYAca831DOBig,2049
7
- telegram_libs/utils.py,sha256=BQvv5LkfvHUZrOWZuMADAVUj_4WkFNoo_wBiEM2hYms,1774
8
- telegram_libs-0.1.8.dist-info/LICENSE,sha256=ZXkWPZbCc61L29Gz6ZHPwn1c4Pm0TnfIqtx8jGWi9F4,1069
9
- telegram_libs-0.1.8.dist-info/METADATA,sha256=YBNtXzsRfkgUeumfXZ95HTPWfPyOggJ6E7CWQ-VVxQw,803
10
- telegram_libs-0.1.8.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
11
- telegram_libs-0.1.8.dist-info/RECORD,,