Spaces:
Runtime error
Runtime error
measmonysuon
commited on
Commit
•
b40d49a
1
Parent(s):
564c587
Update app.py
Browse files
app.py
CHANGED
@@ -78,13 +78,6 @@ def get_user_points(user_chat_id):
|
|
78 |
except requests.RequestException as e:
|
79 |
logger.error(f"Error retrieving user points: {e}")
|
80 |
return "Error retrieving points"
|
81 |
-
|
82 |
-
def retrieve_user_points(user_chat_id):
|
83 |
-
"""Retrieve user points and display them."""
|
84 |
-
points = get_user_points(user_chat_id)
|
85 |
-
if points == "Guest":
|
86 |
-
return "Please register with @myexpsupportBot", ""
|
87 |
-
return f"Your current points: {points}", points
|
88 |
|
89 |
def notify_webhook(user_chat_id):
|
90 |
"""Notify the webhook server about the points update."""
|
@@ -97,6 +90,13 @@ def notify_webhook(user_chat_id):
|
|
97 |
except requests.RequestException as e:
|
98 |
logger.error(f"Error sending webhook notification: {e}")
|
99 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
100 |
def extract_user_chat_id_from_url(url):
|
101 |
parsed_url = urlparse(url)
|
102 |
params = parse_qs(parsed_url.query)
|
@@ -108,7 +108,7 @@ def gradio_interface(prompt, resolution_key, user_chat_id):
|
|
108 |
if result and result[0]:
|
109 |
file_path = result[0][0].get('image')
|
110 |
if file_path and os.path.exists(file_path):
|
111 |
-
update_user_points(user_chat_id,
|
112 |
notify_webhook(user_chat_id) # Notify the webhook server
|
113 |
return file_path, "The image was generated successfully."
|
114 |
else:
|
@@ -142,14 +142,14 @@ def create_gradio_interface(user_chat_id):
|
|
142 |
|
143 |
# Create input components
|
144 |
user_chat_id_input = gr.Textbox(
|
145 |
-
label="
|
146 |
placeholder="User Chat ID will be displayed here",
|
147 |
interactive=False # Make this non-editable
|
148 |
)
|
149 |
points_output = gr.Textbox(label="Your Balances", placeholder="User points will be displayed here")
|
150 |
|
151 |
# Create the button to get user points
|
152 |
-
get_points_button = gr.Button("
|
153 |
|
154 |
# Create other components
|
155 |
prompt_input = gr.Textbox(label="Prompt", placeholder="Enter your prompt here...")
|
|
|
78 |
except requests.RequestException as e:
|
79 |
logger.error(f"Error retrieving user points: {e}")
|
80 |
return "Error retrieving points"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
|
82 |
def notify_webhook(user_chat_id):
|
83 |
"""Notify the webhook server about the points update."""
|
|
|
90 |
except requests.RequestException as e:
|
91 |
logger.error(f"Error sending webhook notification: {e}")
|
92 |
|
93 |
+
def retrieve_user_points(user_chat_id):
|
94 |
+
"""Retrieve user points and display them."""
|
95 |
+
points = get_user_points(user_chat_id)
|
96 |
+
if points == "Guest":
|
97 |
+
return "Please register with @myexpsupportBot", ""
|
98 |
+
return f"Your current points: {points}", points
|
99 |
+
|
100 |
def extract_user_chat_id_from_url(url):
|
101 |
parsed_url = urlparse(url)
|
102 |
params = parse_qs(parsed_url.query)
|
|
|
108 |
if result and result[0]:
|
109 |
file_path = result[0][0].get('image')
|
110 |
if file_path and os.path.exists(file_path):
|
111 |
+
update_user_points(user_chat_id, 5) # Award 10 points for each image generated
|
112 |
notify_webhook(user_chat_id) # Notify the webhook server
|
113 |
return file_path, "The image was generated successfully."
|
114 |
else:
|
|
|
142 |
|
143 |
# Create input components
|
144 |
user_chat_id_input = gr.Textbox(
|
145 |
+
label="Your UID",
|
146 |
placeholder="User Chat ID will be displayed here",
|
147 |
interactive=False # Make this non-editable
|
148 |
)
|
149 |
points_output = gr.Textbox(label="Your Balances", placeholder="User points will be displayed here")
|
150 |
|
151 |
# Create the button to get user points
|
152 |
+
get_points_button = gr.Button("Show Your Points")
|
153 |
|
154 |
# Create other components
|
155 |
prompt_input = gr.Textbox(label="Prompt", placeholder="Enter your prompt here...")
|