Skip to content

Commit

Permalink
Improve answers
Browse files Browse the repository at this point in the history
  • Loading branch information
annndruha committed Nov 9, 2023
1 parent 264d5b8 commit 4a0736b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
15 changes: 9 additions & 6 deletions src/answers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@ class Answers:
start = '🤖 I\'m a <a href="https://github.com/Annndruha/issue-github-telegram-bot">bot</a>' \
' for creating a GitHub issue in <a href="https://github.com/{}">your organization</a> repositories' \
' directly from this chat. \nMore info in /help'
help = 'For create an issue, mention me and enter the title of the issue.' \
'\nIf you want to provide a description, after the title break the line and write a ' \
'description. Below is an example of a message to create an issue:' \
'\n\n/issue Issue title\nDescription of issue\nSee more by calling the bot command: /md_guide'
help = 'For create an issue, mention me or call /issue and enter the title of the issue. ' \
'If you want to provide a description, break the line after title and write a ' \
'description. See more in markdown guide: /md_guide\n\n**Examples how to call me:**'
help_example = '/issue Just only title'
help_example2 = '/issue Issue title\nText description of issue\n'
help_example3 = '{} Issue title\nCall via mention, and long description with some code example:\n' \
'```python\nimport bug\nbug.fix()```'
no_title = 'After the mention, you need to enter the title of the issue. More in /help'
markdown_guide_tg = 'Supported Telegram styling which will be properly converted to GitHub Markdown:' \
'\n\n<i>italic</i>' \
Expand All @@ -29,10 +32,10 @@ class Answers:
'\n\n$latex = \\frac{e^5}{\\pi}$' \
'\n**bold**' \
'\n*italic*' \
'\n`inline_code_block `' \
'\n`inline_code_block`' \
'\n\n```python' \
'\n# code block' \
'\nprint("Hello, issue bot!")' \
'\n```' \
'\n\n[link](github.com)'\
'\n\n[link](github.com)' \
'\n![image_link](link.to/some_image.png)'
16 changes: 9 additions & 7 deletions src/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
ans = Answers()
settings = Settings()
github = Github(settings)
HTML = ParseMode('HTML')
HTML = ParseMode.HTML
MARKDOWN_V2 = ParseMode.MARKDOWN_V2


@errors_solver
Expand All @@ -34,11 +35,12 @@ async def handler_start(update: Update, context: ContextTypes.DEFAULT_TYPE):
@errors_solver
@log_formatter
async def handler_help(update: Update, context: ContextTypes.DEFAULT_TYPE):
await context.bot.send_message(chat_id=update.message.chat_id,
message_thread_id=update.message.message_thread_id,
text=ans.help,
disable_web_page_preview=True,
parse_mode=HTML)
for text in [ans.help, ans.help_example, ans.help_example2, ans.help_example3.format(settings.BOT_NICKNAME)]:
await context.bot.send_message(chat_id=update.message.chat_id,
message_thread_id=update.message.message_thread_id,
text=text,
disable_web_page_preview=True,
parse_mode=HTML)


@errors_solver
Expand All @@ -52,7 +54,7 @@ async def handler_md_guide(update: Update, context: ContextTypes.DEFAULT_TYPE):
await context.bot.send_message(chat_id=update.message.chat_id,
message_thread_id=update.message.message_thread_id,
text=ans.markdown_guide_md,
disable_web_page_preview=True, )
disable_web_page_preview=True)


@errors_solver
Expand Down

0 comments on commit 4a0736b

Please sign in to comment.