Add Telegram bot support #23

Merged
Berack96 merged 23 commits from 6-telegram-interface into main 2025-10-13 10:49:46 +02:00
Berack96 commented 2025-10-09 13:55:05 +02:00 (Migrated from github.com)

Introduce a Telegram bot with command handling and inline keyboard functionality. Update configuration management to support conversation states and message handling. Enhance logging and include PDF report generation capabilities. Update dependencies and project structure for better functionality.

Introduce a Telegram bot with command handling and inline keyboard functionality. Update configuration management to support conversation states and message handling. Enhance logging and include PDF report generation capabilities. Update dependencies and project structure for better functionality.
copilot-pull-request-reviewer[bot] (Migrated from github.com) reviewed 2025-10-09 13:55:41 +02:00
copilot-pull-request-reviewer[bot] (Migrated from github.com) left a comment

Pull Request Overview

This PR introduces Telegram bot functionality to the crypto analysis application while updating configuration management and improving logging. The changes add a Telegram bot with command handling, inline keyboards, and PDF report generation, while replacing custom logging with standard Python logging throughout the codebase.

  • Add comprehensive Telegram bot support with conversation states and command handling
  • Replace custom logging system with standard Python logging and colored output
  • Update project dependencies to include Telegram bot and PDF generation libraries

Reviewed Changes

Copilot reviewed 12 out of 14 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/app/utils/telegram_app.py New comprehensive Telegram bot implementation with conversation handling and PDF reports
src/app/utils/wrapper_handler.py Replace custom logging with standard Python logging
src/app/utils/chat_manager.py Add Gradio interface methods and pipeline integration
src/app/utils/init.py Export new BotFunctions class
src/app/social/reddit.py Add check_for_async parameter to Reddit client
src/app/agents/pipeline.py Convert instance variables to class variables and update logging
src/app/agents/models.py Replace custom logging with standard Python logging
src/app/main.py Complete rewrite to support both Gradio and Telegram interfaces with improved logging
pyproject.toml Add dependencies for Telegram bot and colored logging
demos/telegram_bot_demo.py Add Telegram bot demonstration script
README.md Update documentation to mention Telegram bot support
.env.example Add Telegram bot token configuration

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

## Pull Request Overview This PR introduces Telegram bot functionality to the crypto analysis application while updating configuration management and improving logging. The changes add a Telegram bot with command handling, inline keyboards, and PDF report generation, while replacing custom logging with standard Python logging throughout the codebase. - Add comprehensive Telegram bot support with conversation states and command handling - Replace custom logging system with standard Python logging and colored output - Update project dependencies to include Telegram bot and PDF generation libraries ### Reviewed Changes Copilot reviewed 12 out of 14 changed files in this pull request and generated 2 comments. <details> <summary>Show a summary per file</summary> | File | Description | | ---- | ----------- | | src/app/utils/telegram_app.py | New comprehensive Telegram bot implementation with conversation handling and PDF reports | | src/app/utils/wrapper_handler.py | Replace custom logging with standard Python logging | | src/app/utils/chat_manager.py | Add Gradio interface methods and pipeline integration | | src/app/utils/__init__.py | Export new BotFunctions class | | src/app/social/reddit.py | Add check_for_async parameter to Reddit client | | src/app/agents/pipeline.py | Convert instance variables to class variables and update logging | | src/app/agents/models.py | Replace custom logging with standard Python logging | | src/app/__main__.py | Complete rewrite to support both Gradio and Telegram interfaces with improved logging | | pyproject.toml | Add dependencies for Telegram bot and colored logging | | demos/telegram_bot_demo.py | Add Telegram bot demonstration script | | README.md | Update documentation to mention Telegram bot support | | .env.example | Add Telegram bot token configuration | </details> --- <sub>**Tip:** Customize your code reviews with copilot-instructions.md. <a href="/Berack96/upo-appAI/new/main/.github?filename=copilot-instructions.md" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Create the file</a> or <a href="https://docs.github.com/en/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">learn how to get started</a>.</sub>
@@ -0,0 +1,264 @@
import io
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2025-10-09 13:55:41 +02:00

Comment is in Italian and not descriptive. Consider using English and explaining why the typing is complex.

    # Typing for users_req is complex because it maps User objects to ConfigsRun instances.
Comment is in Italian and not descriptive. Consider using English and explaining why the typing is complex. ```suggestion # Typing for users_req is complex because it maps User objects to ConfigsRun instances. ```
@@ -0,0 +79,4 @@
app.add_error_handler(self.__error_handler)
app.add_handler(ConversationHandler(
per_message=False, # capire a cosa serve perchè da un warning quando parte il server
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2025-10-09 13:55:41 +02:00

Comment is in Italian. Consider translating to English: '# understand what this does because it gives a warning when the server starts'

            per_message=False, # understand what this does because it gives a warning when the server starts
Comment is in Italian. Consider translating to English: '# understand what this does because it gives a warning when the server starts' ```suggestion per_message=False, # understand what this does because it gives a warning when the server starts ```
copilot-pull-request-reviewer[bot] (Migrated from github.com) reviewed 2025-10-12 20:27:15 +02:00
copilot-pull-request-reviewer[bot] (Migrated from github.com) left a comment

Pull Request Overview

Copilot reviewed 12 out of 14 changed files in this pull request and generated 6 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

## Pull Request Overview Copilot reviewed 12 out of 14 changed files in this pull request and generated 6 comments. --- <sub>**Tip:** Customize your code reviews with copilot-instructions.md. <a href="/Berack96/upo-appAI/new/main/.github?filename=copilot-instructions.md" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Create the file</a> or <a href="https://docs.github.com/en/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">learn how to get started</a>.</sub>
@@ -0,0 +5,4 @@
# Esempio di funzione per gestire il comando /start
async def start(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
if not update.message: return
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2025-10-12 20:27:14 +02:00

[nitpick] Consider using explicit None return for better code clarity: 'return None' instead of bare 'return'.

    if not update.message: return None
[nitpick] Consider using explicit None return for better code clarity: 'return None' instead of bare 'return'. ```suggestion if not update.message: return None ```
@@ -0,0 +12,4 @@
# Esempio di funzione per fare echo del messaggio ricevuto
async def echo(update: Update, context: ContextTypes.DEFAULT_TYPE):
message = update.message
if not message: return
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2025-10-12 20:27:14 +02:00

[nitpick] Consider using explicit None return for better code clarity: 'return None' instead of bare 'return'.

    if not message: return None
[nitpick] Consider using explicit None return for better code clarity: 'return None' instead of bare 'return'. ```suggestion if not message: return None ```
@@ -0,0 +20,4 @@
# Esempio di funzione per far partire una inline keyboard (comando /keyboard)
async def inline_keyboard(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
if not update.message: return
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2025-10-12 20:27:14 +02:00

[nitpick] Consider using explicit None return for better code clarity: 'return None' instead of bare 'return'.

    if not update.message: return None
[nitpick] Consider using explicit None return for better code clarity: 'return None' instead of bare 'return'. ```suggestion if not update.message: return None ```
@@ -0,0 +33,4 @@
async def button_handler(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
query = update.callback_query
if not query: return
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2025-10-12 20:27:14 +02:00

[nitpick] Consider using explicit None return for better code clarity: 'return None' instead of bare 'return'.

    if not query: return None
[nitpick] Consider using explicit None return for better code clarity: 'return None' instead of bare 'return'. ```suggestion if not query: return None ```
@@ -0,0 +79,4 @@
app.add_error_handler(self.__error_handler)
app.add_handler(ConversationHandler(
per_message=False, # capire a cosa serve perchè da un warning quando parte il server
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2025-10-12 20:27:13 +02:00

Corrected spelling of 'perchè' to 'perché' in Italian comment.

            per_message=False, # capire a cosa serve perché da un warning quando parte il server
Corrected spelling of 'perchè' to 'perché' in Italian comment. ```suggestion per_message=False, # capire a cosa serve perché da un warning quando parte il server ```
@@ -0,0 +222,4 @@
return ConversationHandler.END
async def __run_team(self, update: Update, confs: ConfigsRun) -> None:
if not update.message: return
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2025-10-12 20:27:13 +02:00

[nitpick] Consider using explicit None return for better code clarity: 'return None' instead of bare 'return'.

        if not update.message: return None
[nitpick] Consider using explicit None return for better code clarity: 'return None' instead of bare 'return'. ```suggestion if not update.message: return None ```
copilot-pull-request-reviewer[bot] (Migrated from github.com) reviewed 2025-10-13 10:47:13 +02:00
copilot-pull-request-reviewer[bot] (Migrated from github.com) left a comment

Pull Request Overview

Copilot reviewed 13 out of 15 changed files in this pull request and generated 1 comment.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

## Pull Request Overview Copilot reviewed 13 out of 15 changed files in this pull request and generated 1 comment. --- <sub>**Tip:** Customize your code reviews with copilot-instructions.md. <a href="/Berack96/upo-appAI/new/main/.github?filename=copilot-instructions.md" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Create the file</a> or <a href="https://docs.github.com/en/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">learn how to get started</a>.</sub>
@@ -21,2 +20,3 @@
label: Gemini Pro
# - name: gemini-2.0-pro # TODO Non funziona, ha un nome diverso
# label: Gemini Pro
ollama:
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2025-10-13 10:47:12 +02:00

The Italian comment contains a spelling error: 'Non funziona' should be 'Non funziona' (already correct), but 'ha' should be 'ha' (already correct). However, there's inconsistent capitalization - 'Non' should be lowercase 'non' in Italian.

    # - name: gemini-2.0-pro # TODO non funziona, ha un nome diverso
The Italian comment contains a spelling error: 'Non funziona' should be 'Non funziona' (already correct), but 'ha' should be 'ha' (already correct). However, there's inconsistent capitalization - 'Non' should be lowercase 'non' in Italian. ```suggestion # - name: gemini-2.0-pro # TODO non funziona, ha un nome diverso ```
Sign in to join this conversation.