VietCat commited on
Commit
8d3e636
·
1 Parent(s): fa9fe3e

fix duplicate message

Browse files
Files changed (1) hide show
  1. app/main.py +6 -1
app/main.py CHANGED
@@ -240,11 +240,14 @@ async def process_message(message_data: Dict[str, Any]):
240
  for key, value in log_kwargs.items():
241
  if value not in (None, "", []) and conv.get(key) in (None, "", []):
242
  conv[key] = value
243
- logger.info(f"[DEBUG] Message history sau update: {conv}")
244
  # Thêm timestamp mới nếu chưa có
245
  conv['timestamp'] = flatten_timestamp(conv['timestamp'])
246
  if timestamp not in conv['timestamp']:
247
  conv['timestamp'].append(timestamp)
 
 
 
 
248
 
249
  # Get page access token (sync)
250
  page_token = supabase_client.get_page_token(page_id)
@@ -258,6 +261,8 @@ async def process_message(message_data: Dict[str, Any]):
258
  logger.error(f"No access token found for page {page_id}")
259
  return
260
 
 
 
261
  # Extract command and keywords
262
  command, remaining_text = extract_command(message_text)
263
  # Sử dụng LLM để phân tích message_text và extract keywords, mục đích, hành vi vi phạm
 
240
  for key, value in log_kwargs.items():
241
  if value not in (None, "", []) and conv.get(key) in (None, "", []):
242
  conv[key] = value
 
243
  # Thêm timestamp mới nếu chưa có
244
  conv['timestamp'] = flatten_timestamp(conv['timestamp'])
245
  if timestamp not in conv['timestamp']:
246
  conv['timestamp'].append(timestamp)
247
+
248
+ logger.info(f"[DEBUG] Message history sau update: {conv}")
249
+
250
+ await loop.run_in_executor(executor, lambda: sheets_client.log_conversation(**conv))
251
 
252
  # Get page access token (sync)
253
  page_token = supabase_client.get_page_token(page_id)
 
261
  logger.error(f"No access token found for page {page_id}")
262
  return
263
 
264
+ await facebook_client.send_message(page_token, sender_id, "Ok, để mình check. Bạn chờ mình chút xíu nhé!")
265
+
266
  # Extract command and keywords
267
  command, remaining_text = extract_command(message_text)
268
  # Sử dụng LLM để phân tích message_text và extract keywords, mục đích, hành vi vi phạm