Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -67,19 +67,25 @@ def handle_message():
|
|
67 |
subscription = page_config.get('subscription', 'NONE')
|
68 |
expiration = page_config.get('expiration', 'NONE')
|
69 |
|
70 |
-
#
|
71 |
-
if subscription
|
72 |
from datetime import datetime
|
73 |
try:
|
74 |
expiration_date = datetime.strptime(expiration, "%Y-%m-%d")
|
75 |
current_date = datetime.now()
|
76 |
-
if current_date.date()
|
77 |
-
print(f"Page ID {page_id} has an expired
|
78 |
continue
|
79 |
except Exception as e:
|
80 |
print(f"Error checking expiration date: {str(e)}")
|
|
|
81 |
continue
|
82 |
|
|
|
|
|
|
|
|
|
|
|
83 |
# Fetch the system prompt dynamically for each request
|
84 |
system_prompt = page_config.get('system', 'Default system prompt')
|
85 |
|
@@ -173,10 +179,6 @@ def handle_message():
|
|
173 |
if attachments:
|
174 |
print(f"Basic subscriber tried to send attachments. Skipping...")
|
175 |
continue
|
176 |
-
else:
|
177 |
-
# Non-subscribers can't use the service
|
178 |
-
print(f"Non-subscriber tried to use the service. Skipping...")
|
179 |
-
continue
|
180 |
|
181 |
# Create content based on subscription level
|
182 |
content = []
|
|
|
67 |
subscription = page_config.get('subscription', 'NONE')
|
68 |
expiration = page_config.get('expiration', 'NONE')
|
69 |
|
70 |
+
# Check expiration date for any subscription type that has one
|
71 |
+
if subscription in ["Basic", "Plus"] and expiration != "NONE":
|
72 |
from datetime import datetime
|
73 |
try:
|
74 |
expiration_date = datetime.strptime(expiration, "%Y-%m-%d")
|
75 |
current_date = datetime.now()
|
76 |
+
if current_date.date() > expiration_date.date():
|
77 |
+
print(f"Page ID {page_id} has an expired {subscription} subscription. Skipping...")
|
78 |
continue
|
79 |
except Exception as e:
|
80 |
print(f"Error checking expiration date: {str(e)}")
|
81 |
+
# If there's an error parsing the date, we should skip processing
|
82 |
continue
|
83 |
|
84 |
+
# If no subscription, skip processing
|
85 |
+
if subscription == "NONE":
|
86 |
+
print(f"Page ID {page_id} has no subscription. Skipping...")
|
87 |
+
continue
|
88 |
+
|
89 |
# Fetch the system prompt dynamically for each request
|
90 |
system_prompt = page_config.get('system', 'Default system prompt')
|
91 |
|
|
|
179 |
if attachments:
|
180 |
print(f"Basic subscriber tried to send attachments. Skipping...")
|
181 |
continue
|
|
|
|
|
|
|
|
|
182 |
|
183 |
# Create content based on subscription level
|
184 |
content = []
|