telegram_libs 0.1.35__py3-none-any.whl → 0.1.37__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.
@@ -3,7 +3,7 @@ import os
3
3
  required_constants = []
4
4
 
5
5
  MONGO_URI = os.getenv("MONGO_URI")
6
- SUBSCRIPTION_DB_NAME = os.getenv("SUBSCRIPTION_DB_NAME")
6
+ SUBSCRIPTION_DB_NAME = os.getenv("SUBSCRIPTION_DB_NAME", "subscriptions")
7
7
  LOGS_DB_NAME = os.getenv("LOGS_DB_NAME", "logs")
8
8
  DEBUG = os.getenv("DEBUG", "False").lower() in ("true", "1", "yes")
9
9
  BOTS = {
@@ -13,12 +13,12 @@ BOTS = {
13
13
  "https://t.me/kudapoyti_go_bot": "Recommend Place to Visit",
14
14
  "https://t.me/TryOnOutfitGBot": "Try On Outfit",
15
15
  "https://t.me/CloneVoiceAIGBot": "Clone Voice, Text to Speech AI",
16
+ "https://t.me/SocialPosterGBot": "Social Poster",
16
17
  }
17
18
 
18
19
  BOTS_AMOUNT = len(BOTS)
19
20
 
20
21
  required_constants.append(("MONGO_URI", MONGO_URI))
21
- required_constants.append(("SUBSCRIPTION_DB_NAME", SUBSCRIPTION_DB_NAME))
22
22
 
23
23
  missing_constants = [name for name, value in required_constants if not value]
24
24
  if missing_constants:
@@ -9,7 +9,7 @@
9
9
  "3months": "3 Months - 1100 Stars",
10
10
  "1year": "1 Year - 3600 Stars"
11
11
  },
12
- "info": "Buying a subscription you will get unlimited access to other {0} bots, to see all bots click /more"
12
+ "info": "Buying a subscription you will get unlimited access to this one and to other {0} bots, to see all bots click /more"
13
13
  },
14
14
  "support": {
15
15
  "message": "Write down any questions, issues or suggestions you have, and we will resolve them as soon as possible 👇 ",
telegram_libs/mongo.py CHANGED
@@ -42,25 +42,27 @@ class MongoManager:
42
42
  return self.create_user(user_id)
43
43
  return user_data
44
44
 
45
+ def increment_usage(self, user_id: int, field: str) -> None:
46
+ """Increment a usage field for a user."""
47
+ self.users_collection.update_one(
48
+ {"user_id": user_id}, {"$inc": {field: 1}}, upsert=True
49
+ )
50
+
45
51
  def update_user_data(self, user_id: int, updates: dict) -> None:
46
52
  """Update user data in the database."""
47
- result = self.users_collection.update_one({"user_id": user_id}, {"$set": updates})
48
- if result.matched_count == 0:
49
- # If no document was matched, create a new user
50
- self.create_user(user_id)
51
- self.users_collection.update_one({"user_id": user_id}, {"$set": updates})
53
+ self.users_collection.update_one(
54
+ {"user_id": user_id}, {"$set": updates}, upsert=True
55
+ )
52
56
 
53
57
  def add_order(self, user_id: int, order: dict) -> None:
54
58
  """Add an order to the user's data."""
55
59
  self.payments_collection.insert_one({"user_id": user_id, **order})
56
60
 
57
-
58
61
  def get_orders(self, user_id: int) -> list:
59
62
  """Get all orders for a user."""
60
63
  orders = self.payments_collection.find({"user_id": user_id})
61
64
  return list(orders)
62
65
 
63
-
64
66
  def update_order(self, user_id: int, order_id: int, updates: dict) -> None:
65
67
  """Update an order for a user."""
66
68
  self.payments_collection.update_one(
@@ -71,7 +73,7 @@ class MongoManager:
71
73
  """Get user information from the update object."""
72
74
  user = update.effective_user
73
75
  user_data = self.get_user_data(user.id)
74
-
76
+
75
77
  return {
76
78
  "user_id": user.id,
77
79
  "username": user.username,
@@ -117,4 +119,4 @@ class MongoManager:
117
119
  return False
118
120
 
119
121
  expiration = datetime.fromisoformat(subscription["premium_expiration"])
120
- return expiration > datetime.now()
122
+ return expiration > datetime.now()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: telegram_libs
3
- Version: 0.1.35
3
+ Version: 0.1.37
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
@@ -17,6 +17,7 @@ Description-Content-Type: text/markdown
17
17
 
18
18
  # Telegram Libs
19
19
 
20
+ A framework to build Telegram bots fast.
20
21
  Common functionality for Andrey Gritsaenko's Telegram bots.
21
22
 
22
23
  ## Installation
@@ -24,3 +25,12 @@ Common functionality for Andrey Gritsaenko's Telegram bots.
24
25
  ```bash
25
26
  pip install telegram-libs
26
27
  ```
28
+
29
+ ## Bots using this framework
30
+
31
+ - [Remove Background](https://t.me/MagMediaBot)
32
+ - [Upscale Image](https://t.me/UpscaleImageGBot)
33
+ - [Generate Background](https://t.me/GenerateBackgroundGBot)
34
+ - [Recommend Place to Visit](https://t.me/kudapoyti_go_bot)
35
+ - [Try On Outfit](https://t.me/TryOnOutfitGBot)
36
+ - [Clone Voice, Text to Speech AI](https://t.me/CloneVoiceAIGBot)
@@ -1,17 +1,17 @@
1
1
  telegram_libs/__init__.py,sha256=xrsD5r6ZiJxPapHf1UhQ61z2gHtCCWrzW0CZHvlvXRc,82
2
- telegram_libs/constants.py,sha256=mATa2Pr4YzPGNrqw29kOHK7sSefWvENZ-byPPZCBTc8,958
2
+ telegram_libs/constants.py,sha256=k0gCJxksUY_UDzCfcG5JOsjKofED4rNb631bLO8jJkA,955
3
3
  telegram_libs/error.py,sha256=uomabeEiSP4v4AEpKYbi_gR0l3G003sio6lKl72AinY,453
4
4
  telegram_libs/handlers.py,sha256=d5-4FvjyWcJeN1i3dHTYhF-2P4j7PbM1QElloFR_llg,2417
5
- telegram_libs/locales/en.json,sha256=5GT1mk1xskau1oaku0E6tZ7-aGf3F1qwkJzD_bN0uV8,960
5
+ telegram_libs/locales/en.json,sha256=Vy158h4UR8X_9AGX5VmN8W6tOufOymGmYPjnobb-vXA,976
6
6
  telegram_libs/locales/ru.json,sha256=KvlxUUpwNyiOtDBhUm3U13Gj7UtzLKX5SzHOdkPT6gY,1411
7
7
  telegram_libs/logger.py,sha256=oikvkZMk2kOLvQI9hVMUGMCoSnOPf_fhMvv2SbO-STo,891
8
- telegram_libs/mongo.py,sha256=j1UIGnldvaNZaFPltCvEUcUOOCoquBWvqPh7Q2HTrvY,4776
8
+ telegram_libs/mongo.py,sha256=IbPdmBNZKRr8uGUgl7Ew44g56F2O5Js4s1BuT4CawzY,4807
9
9
  telegram_libs/payment.py,sha256=cNb2vnBlYI_6KnTGz-PCM0uKahW2uGjHVn1mGYlYG-4,3564
10
10
  telegram_libs/subscription.py,sha256=NJlh1kcDfasX1XLpkVfe1UbZslpWSC1hXHaum0kfG8A,4693
11
11
  telegram_libs/support.py,sha256=a3BA7g3seVBUMasv65SzxebLayLigA069wvDcStYbCM,2748
12
12
  telegram_libs/translation.py,sha256=8Kb2cgqKKZH4X_i2Le0V_K1imZdoaCzYAca831DOBig,2049
13
13
  telegram_libs/utils.py,sha256=nWYbsY8wjOGCBINhjedkhhp8qoyP51iFZm6lt-u_UF8,5052
14
- telegram_libs-0.1.35.dist-info/LICENSE,sha256=ZXkWPZbCc61L29Gz6ZHPwn1c4Pm0TnfIqtx8jGWi9F4,1069
15
- telegram_libs-0.1.35.dist-info/METADATA,sha256=lWTjJIzGXehwZtC3Ltk85rT3Gp-dPa8b_6sTD14FSj4,804
16
- telegram_libs-0.1.35.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
17
- telegram_libs-0.1.35.dist-info/RECORD,,
14
+ telegram_libs-0.1.37.dist-info/LICENSE,sha256=ZXkWPZbCc61L29Gz6ZHPwn1c4Pm0TnfIqtx8jGWi9F4,1069
15
+ telegram_libs-0.1.37.dist-info/METADATA,sha256=0JmJ2-MPkQmj3ff71U9egL0nj9xA-ht2yOkI8aMfkRs,1208
16
+ telegram_libs-0.1.37.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
17
+ telegram_libs-0.1.37.dist-info/RECORD,,