0
0
mirror of https://gitflic.ru/project/maks1ms/ocab.git synced 2024-12-23 16:23:01 +03:00

добавлены правки

This commit is contained in:
Maxim Slipenko 2024-07-14 16:33:41 +03:00
parent 36dbab06d3
commit 8b7e8e1170
8 changed files with 68 additions and 59 deletions

View File

@ -20,7 +20,7 @@ bot_modules = [
FSLoader(f"{paths.modules_standard}/command_helper"),
FSLoader(f"{paths.modules_standard}/info"),
FSLoader(f"{paths.modules_standard}/filters"),
FSLoader(f"{paths.modules_standard}/create_report_apps"),
FSLoader(f"{paths.modules_external}/create_report_apps"),
FSLoader(f"{paths.modules_standard}/admin"),
FSLoader(f"{paths.modules_standard}/message_processing"),
]

View File

@ -11,7 +11,7 @@ class ModuleInfo:
name: str
description: str
version: str
author: str
author: str | list[str]
privileged: bool
dependencies: dict

View File

@ -129,8 +129,8 @@ async def additional_info_entered(message: Message, state: FSMContext):
data = await state.get_data()
report = Report(data)
file_report = report.export(html=False).encode()
file_report = report.export().encode()
await message.answer(text=report.export(html=True), parse_mode=ParseMode.HTML)
await message.answer(text=report.export())
await message.answer_document(document=BufferedInputFile(file_report, "report.txt"))
await state.clear()

View File

@ -1,8 +1,11 @@
{
"id": "standard.create_report_apps",
"id": "external.create_report_apps",
"name": "Create Report Apps",
"description": "Модуль для создания отчетов о ошибках в приложениях",
"author": "OCAB Team",
"author": [
"OCAB Team",
"Maxim Slipenko"
],
"version": "1.0.0",
"privileged": false,
"dependencies": {

View File

@ -0,0 +1,59 @@
import aiogram
class ReportFormatter:
def __init__(self, html=True):
self.html = html
def bold(self, string):
if self.html:
return f"<b>{self.text(string)}</b>"
return self.text(string)
def text(self, string):
if self.html:
return aiogram.html.quote(string)
return string
class Report:
def __init__(self, data: dict):
self.data = data
def export(self):
data = self.data
report = f"""
Стенд с ошибкой:
==============================
{data['system']}
Пакет:
==============================
{data['app']}
Шаги, приводящие к ошибке:
==============================
{data['problem_step_by_step']}
Фактический результат:
==============================
{data['actual']}
Ожидаемый результат:
==============================
{data['expected']}
"""
if data["additional"] != "":
report += f"""
Дополнительно:
==============================
{data['additional']}
"""
return report

View File

@ -1,53 +0,0 @@
import aiogram
class ReportFormatter:
def __init__(self, html=True):
self.html = html
def bold(self, string):
if self.html:
return f"<b>{self.text(string)}</b>"
return self.text(string)
def text(self, string):
if self.html:
return aiogram.html.quote(string)
return string
class Report:
def __init__(self, data: dict):
self.data = data
def export(self, html=True):
data = self.data
f = ReportFormatter(html)
report = f"""{f.bold("Стенд с ошибкой:")}
{f.text(data['system'])}
{f.bold("Версия программы:")}
{f.text(data['app'])}
{f.bold("Шаги, приводящие к ошибке:")}
{f.text(data['problem_step_by_step'])}
{f.bold("Результат:")}
{f.text(data['actual'])}
{f.bold("Ожидаемый результат:")}
{f.text(data['expected'])}
"""
if data["additional"] != "":
report += f"""{f.bold("Дополнительно:")}
{f.text(data['additional'])}
"""
return report