Update chatbot/plugins/chat.py
Browse files- chatbot/plugins/chat.py +13 -13
chatbot/plugins/chat.py
CHANGED
@@ -92,7 +92,6 @@ blacklist_patterns = [
|
|
92 |
r"\bdeath\s*threat\b",
|
93 |
]
|
94 |
|
95 |
-
|
96 |
def is_command_disabled(text):
|
97 |
text_lower = text.lower()
|
98 |
if text_lower.startswith("/") and not (text_lower.startswith("/setmodel") or text_lower.startswith("/start")):
|
@@ -1158,20 +1157,21 @@ async def chatbot_talk(client: Client, message: Message):
|
|
1158 |
user_data.get("is_premium", False) and
|
1159 |
user_data.get("premium_expiry", dt.min) > dt.now()
|
1160 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1161 |
await db.user_premium.update_one(
|
1162 |
{"user_id": message.from_user.id},
|
1163 |
-
|
1164 |
-
"$inc": {"credits_used": 1},
|
1165 |
-
"$set": {
|
1166 |
-
"last_reset": user_data["last_reset"],
|
1167 |
-
"is_premium": is_active_premium
|
1168 |
-
},
|
1169 |
-
"$setOnInsert": {
|
1170 |
-
"credits_used": 0,
|
1171 |
-
"last_reset": dt.now(),
|
1172 |
-
"premium_expiry": None
|
1173 |
-
}
|
1174 |
-
},
|
1175 |
upsert=True
|
1176 |
)
|
1177 |
await client.send_chat_action(message.chat.id, enums.ChatAction.CANCEL)
|
|
|
92 |
r"\bdeath\s*threat\b",
|
93 |
]
|
94 |
|
|
|
95 |
def is_command_disabled(text):
|
96 |
text_lower = text.lower()
|
97 |
if text_lower.startswith("/") and not (text_lower.startswith("/setmodel") or text_lower.startswith("/start")):
|
|
|
1157 |
user_data.get("is_premium", False) and
|
1158 |
user_data.get("premium_expiry", dt.min) > dt.now()
|
1159 |
)
|
1160 |
+
new_credits_used = user_data.get("credits_used", 0) + 1
|
1161 |
+
should_reset = (dt.now() - user_data.get("last_reset", dt.now())) > timedelta(days=1)
|
1162 |
+
update = {
|
1163 |
+
"$set": {
|
1164 |
+
"credits_used": 1 if should_reset else new_credits_used,
|
1165 |
+
"last_reset": dt.now() if should_reset else user_data["last_reset"],
|
1166 |
+
"is_premium": is_active_premium
|
1167 |
+
}
|
1168 |
+
}
|
1169 |
+
if "premium_expiry" not in user_data:
|
1170 |
+
update["$set"]["premium_expiry"] = None
|
1171 |
+
|
1172 |
await db.user_premium.update_one(
|
1173 |
{"user_id": message.from_user.id},
|
1174 |
+
update,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1175 |
upsert=True
|
1176 |
)
|
1177 |
await client.send_chat_action(message.chat.id, enums.ChatAction.CANCEL)
|