| | |
| | | await db.delete_rp_action(action_id) |
| | | await db.add_log(chat_id, user["user_id"], 0, "rp_delete", action["trigger"], now_ts()) |
| | | return web.json_response({"ok": True}) |
| | | |
| | | |
| | | async def api_rp_toggle(request) -> web.Response: |
| | | user = await _user(request) |
| | | data = await request.post() |
| | | try: |
| | | action_id = int(data["action_id"]) |
| | | chat_id = int(data["chat_id"]) |
| | | enabled = data.get("enabled") == "1" |
| | | except (KeyError, ValueError): |
| | | return web.json_response({"ok": False, "msg": "Некорректные данные."}, status=400) |
| | | |
| | | if chat_id not in await _allowed_ids(user["user_id"]): |
| | | return web.json_response({"ok": False, "msg": "Нет доступа."}, status=403) |
| | | |
| | | action = await db.get_rp_action(action_id) |
| | | if not action or action["chat_id"] != chat_id: |
| | | return web.json_response({"ok": False, "msg": "Действие не найдено."}, status=404) |
| | | |
| | | await db.set_rp_action_enabled(action_id, enabled) |
| | | await db.add_log(chat_id, user["user_id"], 0, "rp_enable" if enabled else "rp_disable", action["trigger"], now_ts()) |
| | | return web.json_response({"ok": True}) |