Skip to content

Commit

Permalink
Merge pull request #17 from DXS-GROUP/InDev
Browse files Browse the repository at this point in the history
Fix
  • Loading branch information
Nighty3098 authored Sep 3, 2024
2 parents eb0f333 + a3a2da6 commit d6249f4
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 29 deletions.
4 changes: 2 additions & 2 deletions src/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from kb_builder import back_btn, main_kb
from resources.TEXT_MESSAGES import (BUG_TEXT, DEVS_TEXT, DONE_TEXT,
HELLO_MESSAGE, IDEA_TEXT,
OUR_PRODUCTS_TEXT, SUPPORT_TEXT)
OUR_PRODUCTS_TEXT, SUPPORT_TEXT, INCORRECT_INPUT_FORMAT_ERROR)
from send_data import send_messages
from send_logs import send_log_to_dev
from StatesGroup import GetBug, GetIdea
Expand Down Expand Up @@ -66,7 +66,7 @@ async def send_admin_answer(message: Message):
parts = message.text.split(" | ")

if len(parts) != 3:
logger.error("Incorrect input format")
logger.error(INCORRECT_INPUT_FORMAT_ERROR)
else:
client_id = parts[1]
source_message = parts[2]
Expand Down
20 changes: 8 additions & 12 deletions src/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@


@dp.callback_query(F.data == "SuggestIdea")
async def GetUserIdea(callback: types.CallbackQuery, state: FSMContext):
async def get_users_idea(callback: types.CallbackQuery, state: FSMContext):
try:
await state.set_state(GetIdea.wait_for_message)
logger.debug(f"{callback.message.chat.id} - idea suggest")
Expand All @@ -42,7 +42,7 @@ async def GetUserIdea(callback: types.CallbackQuery, state: FSMContext):


@dp.callback_query(F.data == "BugReport")
async def GetUserBug(callback: types.CallbackQuery, state: FSMContext):
async def get_users_bug(callback: types.CallbackQuery, state: FSMContext):
try:
await state.set_state(GetBug.wait_for_message)
logger.debug(f"{callback.message.chat.id} - bug report")
Expand All @@ -63,7 +63,7 @@ async def GetUserBug(callback: types.CallbackQuery, state: FSMContext):


@dp.message(GetIdea.wait_for_message)
async def IdeaUserMessage(message: Message, state: FSMContext):
async def user_message_idea(message: Message, state: FSMContext):
try:
username = message.from_user.username
logger.debug(f"Idea suggest from {username}: {message.text}")
Expand Down Expand Up @@ -93,7 +93,7 @@ async def IdeaUserMessage(message: Message, state: FSMContext):


@dp.message(GetBug.wait_for_message)
async def BugUserMessage(message: types.Message, state: FSMContext):
async def user_message_bug(message: types.Message, state: FSMContext):
try:
username = message.from_user.username
logger.debug(f"Bug report from {username}: {message.text}")
Expand Down Expand Up @@ -125,8 +125,6 @@ async def BugUserMessage(message: types.Message, state: FSMContext):
@dp.message(GetIdea.done)
async def send_done_message_idea(message: types.Message, state: FSMContext):
try:
username = message.from_user.username
user_id = message.from_user.id
logger.debug(await message.answer(DONE_TEXT))

except Exception as err:
Expand All @@ -137,8 +135,6 @@ async def send_done_message_idea(message: types.Message, state: FSMContext):
@dp.message(GetBug.done)
async def send_done_message_bug(message: types.Message, state: FSMContext):
try:
username = message.from_user.username
user_id = message.from_user.id
logger.debug(await message.answer(DONE_TEXT))

except Exception as err:
Expand All @@ -147,7 +143,7 @@ async def send_done_message_bug(message: types.Message, state: FSMContext):


@dp.callback_query(F.data == "Back")
async def BackToStartMenu(callback: types.CallbackQuery, state: FSMContext):
async def back_to_menu(callback: types.CallbackQuery, state: FSMContext):
try:
logger.debug(f"{callback.message.chat.id} - back button")
message_id = callback.message.message_id
Expand All @@ -170,7 +166,7 @@ async def BackToStartMenu(callback: types.CallbackQuery, state: FSMContext):


@dp.callback_query(F.data == "Contacts")
async def Contacts(callback: types.CallbackQuery):
async def contacts(callback: types.CallbackQuery):
try:
user_id = callback.from_user.id
logger.debug(f"{user_id} - contacts")
Expand All @@ -191,7 +187,7 @@ async def Contacts(callback: types.CallbackQuery):


@dp.callback_query(F.data == "OurProducts")
async def OurProducts(callback: types.CallbackQuery):
async def our_products(callback: types.CallbackQuery):
try:
user_id = callback.from_user.id
logger.debug(f"{user_id} - our products")
Expand All @@ -213,7 +209,7 @@ async def OurProducts(callback: types.CallbackQuery):


@dp.callback_query(F.data == "SupportMe")
async def SupportMe(callback: types.CallbackQuery):
async def support_me(callback: types.CallbackQuery):
try:
user_id = callback.from_user.id
logger.debug(f"{user_id} - support me")
Expand Down
2 changes: 2 additions & 0 deletions src/resources/TEXT_MESSAGES.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,5 @@
`UQCF-sPDO0QqkNtvy5CKSvYWEsZS6l7vzaytV36oYM0SNhKt`
"""

INCORRECT_INPUT_FORMAT_ERROR = "Incorrect input format"
32 changes: 17 additions & 15 deletions src/send_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
from db.check_for_qsl_injection import is_sql_injection_attempt
from db.db import get_id_by_message, create_connection

DEFAULT_CAPTION = "No description provided."

async def send_messages(message: types.Message, username: str, status: str, date: str):
forward_text = ""
channel_message = (
Expand All @@ -24,34 +26,34 @@ async def send_messages(message: types.Message, username: str, status: str, date

if message.text:
forward_text += message.text
id = await get_id_by_message(await create_connection(), forward_text, date, message.from_user.id, status.lower())
channel_message += f"`/set_ticket_status | {id} | {status.lower()} | status`\n"
channel_message += f"`/get_ticket_status | {id} | {status.lower()}`\n"
message_id = await get_id_by_message(await create_connection(), forward_text, date, message.from_user.id, status.lower())
channel_message += f"`/set_ticket_status | {message_id} | {status.lower()} | status`\n"
channel_message += f"`/get_ticket_status | {message_id} | {status.lower()}`\n"

if message.photo:
photo = message.photo[-1]
caption = message.caption if message.caption else "No description provided."
id = await get_id_by_message(await create_connection(), caption, date, message.from_user.id, status.lower())
channel_message += f"`/set_ticket_status | {id} | {status.lower()} | status`\n"
channel_message += f"`/get_ticket_status | {id} | {status.lower()}`\n"
caption = message.caption if message.caption else DEFAULT_CAPTION
message_id = await get_id_by_message(await create_connection(), caption, date, message.from_user.id, status.lower())
channel_message += f"`/set_ticket_status | {message_id} | {status.lower()} | status`\n"
channel_message += f"`/get_ticket_status | {message_id} | {status.lower()}`\n"
channel_message += f"\n🔥 Report: {caption}"
await bot.send_photo(chat_id=CHANNEL, photo=photo.file_id, caption=channel_message, parse_mode="Markdown")

elif message.document:
document = message.document
caption = message.caption if message.caption else "No description provided."
id = await get_id_by_message(await create_connection(), caption, date, message.from_user.id, status.lower())
channel_message += f"`/set_ticket_status | {id} | {status.lower()} | status`\n"
channel_message += f"`/get_ticket_status | {id} | {status.lower()}`\n"
caption = message.caption if message.caption else DEFAULT_CAPTION
message_id = await get_id_by_message(await create_connection(), caption, date, message.from_user.id, status.lower())
channel_message += f"`/set_ticket_status | {message_id} | {status.lower()} | status`\n"
channel_message += f"`/get_ticket_status | {message_id} | {status.lower()}`\n"
channel_message += f"\n🔥 Report: {caption}"
await bot.send_document(chat_id=CHANNEL, document=document.file_id, caption=channel_message, parse_mode="Markdown")

elif message.video:
video = message.video
caption = message.caption if message.caption else "No description provided."
id = await get_id_by_message(await create_connection(), caption, date, message.from_user.id, status.lower())
channel_message += f"`/set_ticket_status | {id} | {status.lower()} | status`\n"
channel_message += f"`/get_ticket_status | {id} | {status.lower()}`\n"
caption = message.caption if message.caption else DEFAULT_CAPTION
message_id = await get_id_by_message(await create_connection(), caption, date, message.from_user.id, status.lower())
channel_message += f"`/set_ticket_status | {message_id} | {status.lower()} | status`\n"
channel_message += f"`/get_ticket_status | {message_id} | {status.lower()}`\n"
channel_message += f"\n🔥 Report: {caption}"
await bot.send_video(chat_id=CHANNEL, video=video.file_id, caption=channel_message, parse_mode="Markdown")

Expand Down

0 comments on commit d6249f4

Please sign in to comment.