Skip to content

Fix bot commands not responding and enable markdown rendering#48

Draft
fyaz05 wants to merge 2 commits into
mainfrom
fix-bot-commands-markdown-rendering
Draft

Fix bot commands not responding and enable markdown rendering#48
fyaz05 wants to merge 2 commits into
mainfrom
fix-bot-commands-markdown-rendering

Conversation

@fyaz05

@fyaz05 fyaz05 commented Jun 2, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes two issues:

  1. Bot commands not responding - pytdbot was filtering out is_outgoing=True messages by default, causing command handlers to never trigger
  2. Markdown/HTML not rendering - Bot messages were displaying raw markdown instead of formatted text

Changes

Thunder/message_patch.py (new)

  • Patches pytdbot's Client.__init__ to add MessageText to allow_outgoing_message_types
  • This allows incoming command messages to be processed even when marked as "outgoing" by TDLib

Thunder/bot/init.py

  • Import message_patch before Client initialization
  • Set default_parse_mode="markdown" on StreamBot client for proper message formatting

Testing

The bot now correctly:

  • Responds to /start, /help, /ping and other commands
  • Renders markdown formatting (bold, code blocks, etc.) in messages

@fyaz05 can click here to continue refining the PR

fyaz05 and others added 2 commits May 21, 2026 21:58
- Replace Pyrogram with Pytdbot for Telegram API operations
- Refactor database from single file to modular mixin-based decomposition
- Add comprehensive rate limiter with exponential backoff and head-of-line blocking avoidance
- Add new utility modules: compat, filters, media_helpers, telegram_helpers, metrics, file_record
- Add unit tests for core functionality (22 tests)
- Add CI pipeline with ruff, pytest, pyright
- Add API and Architecture documentation
- Update Dockerfile with uv package manager and health checks
- Improve error handling and graceful shutdown
- Remove FloodWait exception handling (Pytdbot uses error-return types)
- Add CORS middleware and metrics endpoint
- Clean up repository structure and update .gitignore

Co-Authored-By: Mimo 2.5 Pro
- Add message_patch.py to fix is_outgoing=True messages being filtered
- Set default_parse_mode='markdown' in StreamBot client for proper formatting
- Import message_patch before Client initialization
@coderabbitai

coderabbitai Bot commented Jun 2, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ab787306-4383-4bc0-8842-d3910d138163

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-bot-commands-markdown-rendering

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

Comment @coderabbitai help to get the list of available commands and usage tips.

Comment thread .github/workflows/ci.yml
Comment on lines +11 to +22
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v4
- uses: actions/setup-python@v5
with:
python-version: "3.13"
- run: uv sync
- run: uv run ruff check Thunder/
- run: uv run ruff format --check Thunder/

test:
Comment thread .github/workflows/ci.yml
Comment on lines +23 to +33
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v4
- uses: actions/setup-python@v5
with:
python-version: "3.13"
- run: uv sync
- run: uv run pytest tests/ -v --tb=short

typecheck:
Comment thread .github/workflows/ci.yml
Comment on lines +34 to +42
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v4
- uses: actions/setup-python@v5
with:
python-version: "3.13"
- run: uv sync
- run: uv run pyright Thunder/ --level basic
class BitlyPlugin(ShortenerPlugin):
@classmethod
def matches(cls, domain: str) -> bool:
return "bitly.com" in domain
class OuoIoPlugin(ShortenerPlugin):
@classmethod
def matches(cls, domain: str) -> bool:
return "ouo.io" in domain
except (InvalidHash, FileNotFound) as e:
raise web.HTTPNotFound(text="Resource not found") from e
except RateLimited as e:
raise web.HTTPTooManyRequests(text=str(e)) from e
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.

3 participants