נפתר API מבצע פעולה פעמיים ועזרה עם TIMEOUT.
-
שלום, יש לי תקלה בAPI שאם אני מפעיל איזה פונקציה דרך הAPI עם פרמטרים אז זה מבצע את הפעולה פעמיים, הAPI בשלוחה 0-1. יש בלוגים פער של כמה שניות (לא קבוע) בין הביצוע הראשון לשני של הפעולה...
במקום אחר אני עושה אותה קריאה ושם זה לא מבצע כפול,
זה קטע מהקוד הבעיתי (PYTHON)if step_two == "1" and step_one_target and step_two_plan and step_three_value: if step_two_plan == "1": months = int(step_three_value) if months < 1 or months > 60: return yemot_response("תוקף לא חוקי, הזן מספר בין 1 ל-60", goto="/0/0") plan = "PRO" success, msg = db.change_plan(step_one_target, "PRO", months=months) log_action(phone, "שדרוג משתמש", step_one_target, f"חבילה: {plan}, תוקף: {months} חודשים") prefix = "" if success else "שגיאה: " return yemot_response(prefix + msg, goto="/0/0") elif step_two_plan == "2": units = int(step_three_value) if units < 1: return yemot_response("כמות הודעות לא חוקית", goto="/0/0") plan = "per_message" success, msg = db.change_plan(step_one_target, "per_message", additional_units=units) log_action(phone, "שדרוג משתמש", step_one_target, f"חבילה: {plan}, יחידות: {units}") prefix = "" if success else "שגיאה: " return yemot_response(prefix + msg, goto="/0/0")
זה הקוד שעובד (API אחר בשלוחה אחרת) - אני קורא לAPI עם פרטמרים
pro_months = request.args.get("pro_months") add_units = request.args.get("add_units") with Database() as db: if not phone or not call_id: return yemot_response("שגיאת מערכת חסרים פרמטרים") # ——— שדרוג למסלול PRO ——— if pro_months is not None: try: months = int(pro_months) success, msg = db.change_plan(phone, "PRO", months=months, amount=amount) print(f"שדרוג מספר {phone} למנוי PRO למשך {months} חודשים") if success: return yemot_response(f"מנוי ל {months} חודשים עודכן בהצלחה", goto="/3", voice="AS1000", together="no") else: return yemot_response("שגיאה בעדכון החבילה, נא לפנות לתמיכה", goto="/3", voice="AS1000", together="no") except ValueError: return yemot_response("מספר חודשים לא חוקי", goto="/3", voice="AS1000", together="no") if add_units is not None: try: units = int(add_units) success, msg = db.change_plan(phone, "per_message", additional_units=units, amount=amount) print(f"הוספה למספר {phone} סך {units} יחידות") if success: return yemot_response(f"הוספו {units} יחידות בהצלחה", goto="/3", voice="AS1000", together="no") else: return yemot_response("שגיאה בעדכון היחידות, נא לפנות לתמיכה", goto="/3", voice="AS1000", together="no") except ValueError: return yemot_response("כמות יחידות לא חוקית", goto="/3", voice="AS1000", together="no")
בנוסף, אני מנסה להאריך את הTIMEOUT להמתנה לקלט מהמשתמש, עשיתי ככה:
def yemot_read(phone, call_id, text_prompt, var_name, input_type="Digits", min_len=1, max_len=1, star="", zero="", keys="", timeout="10", seyOK=""): if input_type in ["Digits", "Number"]: input_def = f"{var_name},,{max_len},{min_len},,{input_type},{star},{zero},,{keys},,,,{timeout},{seyOK}"
אבל משום מה לא עובד...
-
@אוריה-דניאלי-0 כתב בAPI מבצע פעולה פעמיים ועזרה עם TIMEOUT.:
יש לי תקלה בAPI שאם אני מפעיל איזה פונקציה דרך הAPI עם פרמטרים אז זה מבצע את הפעולה פעמיים, הAPI בשלוחה 0-1. יש בלוגים פער של כמה שניות (לא קבוע) בין הביצוע הראשון לשני של הפעולה...
מקבלים גם בקשת ניתוק שהשיחה מסתיימת, אתה צריך או להגדיר בשלוחה לא לקבל בקשת api בניתוק, או בקוד עם הגיע ניתוק להתעלם מהבקשה
-
@ערוץ-הסקרים כתב בAPI מבצע פעולה פעמיים ועזרה עם TIMEOUT.:
מקבלים גם בקשת ניתוק שהשיחה מסתיימת, אתה צריך או להגדיר בשלוחה לא לקבל בקשת api בניתוק, או בקוד עם הגיע ניתוק להתעלם מהבקשה
לא כ"כ הבנתי...
-
@אוריה-דניאלי-0
תעשה בדיקה על הערך hangupif request.args.get('hangup') == "yes": return
-
-