|
|
@ -3,7 +3,7 @@ |
|
|
|
|
|
|
|
|
|
|
|
# Сообщения для работы с sql запросами |
|
|
|
# Сообщения для работы с sql запросами |
|
|
|
|
|
|
|
|
|
|
|
from bot_sys import user_access, keyboard |
|
|
|
from bot_sys import user_access, keyboard, bot_messages |
|
|
|
from bot_modules import groups_utils |
|
|
|
from bot_modules import groups_utils |
|
|
|
from template import bd_item, simple_message |
|
|
|
from template import bd_item, simple_message |
|
|
|
|
|
|
|
|
|
|
@ -20,6 +20,7 @@ def GetCancelKeyboardButtonsTemplate(a_AccessFunc, a_AccessMode): |
|
|
|
keyboard.ButtonWithAccess(canсel_button_name, a_AccessMode, a_AccessFunc()) |
|
|
|
keyboard.ButtonWithAccess(canсel_button_name, a_AccessMode, a_AccessFunc()) |
|
|
|
] |
|
|
|
] |
|
|
|
return keyboard.MakeButtons(cur_buttons, a_UserGroups) |
|
|
|
return keyboard.MakeButtons(cur_buttons, a_UserGroups) |
|
|
|
|
|
|
|
return GetCancelKeyboardButtons |
|
|
|
|
|
|
|
|
|
|
|
# TODO CheckAccessString -> CheckAccess |
|
|
|
# TODO CheckAccessString -> CheckAccess |
|
|
|
|
|
|
|
|
|
|
@ -38,7 +39,7 @@ def RequestToBDTemplate(a_Bot, a_StartMessage, a_GetButtonsFunc, a_AccessFunc, a |
|
|
|
def RequestToBDFinishTemplate(a_Bot, a_GetButtonsFunc, a_AccessFunc, a_AccessMode): |
|
|
|
def RequestToBDFinishTemplate(a_Bot, a_GetButtonsFunc, a_AccessFunc, a_AccessMode): |
|
|
|
async def RequestToBDFinish(a_Message, state): |
|
|
|
async def RequestToBDFinish(a_Message, state): |
|
|
|
user_id = str(a_Message.from_user.id) |
|
|
|
user_id = str(a_Message.from_user.id) |
|
|
|
user_groups = groups.GetUserGroupData(a_Bot, user_id) |
|
|
|
user_groups = groups_utils.GetUserGroupData(a_Bot, user_id) |
|
|
|
if not user_access.CheckAccessString(a_AccessFunc(), user_groups, a_AccessMode): |
|
|
|
if not user_access.CheckAccessString(a_AccessFunc(), user_groups, a_AccessMode): |
|
|
|
return await simple_message.AccessDeniedMessage(a_Bot, a_GetButtonsFunc, user_id, a_Message, user_groups) |
|
|
|
return await simple_message.AccessDeniedMessage(a_Bot, a_GetButtonsFunc, user_id, a_Message, user_groups) |
|
|
|
|
|
|
|
|
|
|
@ -46,18 +47,18 @@ def RequestToBDFinishTemplate(a_Bot, a_GetButtonsFunc, a_AccessFunc, a_AccessMod |
|
|
|
async with state.proxy() as prjData: |
|
|
|
async with state.proxy() as prjData: |
|
|
|
if a_Message.text == canсel_button_name: |
|
|
|
if a_Message.text == canсel_button_name: |
|
|
|
await state.finish() |
|
|
|
await state.finish() |
|
|
|
return await simple_message.SendMessage(a_Bot, keyboard.MakeBotMessage(cancel_message), a_GetButtonsFunc, None, user_id, a_Message, user_groups) |
|
|
|
return await simple_message.SendMessage(a_Bot, bot_messages.MakeBotMessage(cancel_message), a_GetButtonsFunc, None, user_id, a_Message, user_groups) |
|
|
|
|
|
|
|
|
|
|
|
sql_request = a_Message.text |
|
|
|
sql_request = a_Message.text |
|
|
|
a_Bot.GetLog().Success(f'Сделан запрос [{sql_request}] пользователем {a_Message.from_user.id}.') |
|
|
|
a_Bot.GetLog().Success(f'Сделан запрос [{sql_request}] пользователем {a_Message.from_user.id}.') |
|
|
|
result, error = a_Bot.SQLReques(sql_request, commit = True, return_error = True) |
|
|
|
result, error = a_Bot.SQLRequest(sql_request, commit = True, return_error = True) |
|
|
|
if not error is None: |
|
|
|
if not error is None: |
|
|
|
a_Bot.GetLog().Error(f'Ошибка при выполнении запроса [{sql_request}] от пользователя {a_Message.from_user.id} ответ следующий [{str(error)}].') |
|
|
|
a_Bot.GetLog().Error(f'Ошибка при выполнении запроса [{sql_request}] от пользователя {a_Message.from_user.id} ответ следующий [{str(error)}].') |
|
|
|
result = str(error) |
|
|
|
result = str(error) |
|
|
|
else: |
|
|
|
else: |
|
|
|
a_Bot.GetLog().Success(f'Результат запроса [{sql_request}] от пользователя {a_Message.from_user.id} следующий [{result}].') |
|
|
|
a_Bot.GetLog().Success(f'Результат запроса [{sql_request}] от пользователя {a_Message.from_user.id} следующий [{result}].') |
|
|
|
await state.finish() |
|
|
|
await state.finish() |
|
|
|
await simple_message.SendMessage(a_Bot, keyboard.MakeBotMessage(str(result)), a_GetButtonsFunc, None, user_id, a_Message, user_groups) |
|
|
|
await simple_message.SendMessage(a_Bot, bot_messages.MakeBotMessage(str(result)), a_GetButtonsFunc, None, user_id, a_Message, user_groups) |
|
|
|
|
|
|
|
|
|
|
|
return RequestToBDFinish |
|
|
|
return RequestToBDFinish |
|
|
|
|
|
|
|
|
|
|
|