Skip to content

Conversation

@cyri113
Copy link
Contributor

@cyri113 cyri113 commented May 28, 2025

Summary by CodeRabbit

  • New Features
    • Introduced dedicated handlers for processing questions, updates, verification, and summary commands in the Telegram bot.
  • Refactor
    • Delegated bot command and event handling to new handler classes for improved modularity.
  • Chores
    • Cleaned up the Docker Compose file by removing unused and commented-out service definitions.

cyri113 added 5 commits May 28, 2025 11:33
…SummaryHandler for Telegram event processing with Temporal integration.
…d remove unused Temporal client integration. Add HandlersModule to manage event handling more effectively.
@coderabbitai
Copy link

coderabbitai bot commented May 28, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This update refactors the bot's architecture by introducing handler classes for processing Telegram commands and updates, moving logic out of the main service. New handler modules are registered, and Temporal workflow invocations are delegated to these handlers. The docker-compose file is simplified by removing unused service definitions.

Changes

File(s) Change Summary
apps/bot/src/bot.module.ts Registers HandlersModule; simplifies Temporal client registration.
apps/bot/src/bot.service.ts Refactors to inject handler classes; delegates command/update handling to handlers; removes old logic.
apps/bot/src/handlers/base.handler.ts Adds abstract BaseHandler class with logging, config, and Temporal client injection.
apps/bot/src/handlers/handlers.module.ts Introduces HandlersModule providing and exporting all handler classes.
apps/bot/src/handlers/question.handler.ts Adds QuestionHandler for processing questions via Temporal workflow.
apps/bot/src/handlers/summary.handler.ts Adds SummaryHandler for summary command via Temporal workflow.
apps/bot/src/handlers/update.handler.ts Adds UpdateHandler for generic update processing via Temporal workflow.
apps/bot/src/handlers/verify.handler.ts Adds VerifyHandler for verification command via Temporal workflow.
docker-compose.yml Removes unused/commented-out services and volumes; minor healthcheck adjustment for rabbitmq.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Telegram
    participant BotService
    participant QuestionHandler
    participant UpdateHandler
    participant VerifyHandler
    participant SummaryHandler
    participant Temporal

    User->>Telegram: Sends message/command
    Telegram->>BotService: Forwards update
    alt Question command
        BotService->>QuestionHandler: handle(ctx)
        QuestionHandler->>Temporal: Start TelegramQuestionWorkflow
        Temporal-->>QuestionHandler: Returns result
        QuestionHandler->>Telegram: Replies to user
    else Update event
        BotService->>UpdateHandler: handle(ctx)
        UpdateHandler->>Temporal: Start TelegramUpdateWorkflow
    else Verify command
        BotService->>VerifyHandler: handle(ctx)
        VerifyHandler->>Temporal: Start TelegramVerifyWorkflow
        Temporal-->>VerifyHandler: Returns result
        VerifyHandler->>Telegram: Replies to user
    else Summary command
        BotService->>SummaryHandler: handle(ctx)
        SummaryHandler->>Temporal: Start TelegramSummaryWorkflow
        Temporal-->>SummaryHandler: Returns result
        SummaryHandler->>Telegram: Replies to user
    end
Loading

Possibly related PRs

  • update telegram to use hivemind agent #31: Alters processQuestion logic in BotService to use different Temporal workflows; related as both PRs modify workflow invocation but this PR moves logic to handlers.
  • add /summary command #34: Adds the original getSummary method in BotService; this PR refactors summary handling into a dedicated handler, directly affecting the same functionality.

Poem

In the warren of code, we burrow anew,
Handlers now hop where the bot once flew.
Workflows dispatched with a flick of the ear,
Docker decluttered, the path is clear.
With every refactor, our tails wag with glee—
More modular magic for all bunnies to see! 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2d76446 and 4bc80fe.

📒 Files selected for processing (9)
  • apps/bot/src/bot.module.ts (2 hunks)
  • apps/bot/src/bot.service.ts (4 hunks)
  • apps/bot/src/handlers/base.handler.ts (1 hunks)
  • apps/bot/src/handlers/handlers.module.ts (1 hunks)
  • apps/bot/src/handlers/question.handler.ts (1 hunks)
  • apps/bot/src/handlers/summary.handler.ts (1 hunks)
  • apps/bot/src/handlers/update.handler.ts (1 hunks)
  • apps/bot/src/handlers/verify.handler.ts (1 hunks)
  • docker-compose.yml (1 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@cyri113 cyri113 merged commit 298502c into main May 28, 2025
3 of 4 checks passed
@coderabbitai coderabbitai bot mentioned this pull request May 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants