Skip to content

Feature/migrate from kotlin telegram bot - #281

Open
alexmcgil wants to merge 13 commits into
feature/agentsfrom
feature/migrate-from-kotlin-telegram-bot
Open

Feature/migrate from kotlin telegram bot#281
alexmcgil wants to merge 13 commits into
feature/agentsfrom
feature/migrate-from-kotlin-telegram-bot

Conversation

@alexmcgil

Copy link
Copy Markdown

Telegram Channel: Library Migration & Streaming Support

Summary

This PR migrates the Telegram channel from kotlin-telegram-bot to the actively maintained java-telegram-bot-api by Pengrad, and adds native streaming support for LLM responses.

Key Changes

  1. Library Migration
  • Before: kotlin-telegram-bot
  • After: java-telegram-bot-api by Pengrad (active development, cleaner API, better community support)
  • All core functionality preserved with backward-compatible public API
  • Type changes: com.github.kotlintelegrambot.* → com.pengrad.telegrambot.*
  1. Streaming Support 🆕
  • Real-time LLM response updates in Telegram messages
  • Configurable update throttling (default: 500ms)
  • Automatic handling of Telegram's 4096 character limit (splits into multiple messages)
  • Optional ParseMode support (Markdown/HTML)
  • Graceful error handling for common Telegram API errors
  1. Configuration

StreamConfig(
updateIntervalMs = 500,
initialPlaceholder = "...",
parseMode = null // or ParseMode.Markdown
)

Breaking Changes

  • Direct API access type changed: reactions.telegram?.api now returns TelegramBot (Pengrad) instead of Bot (kotlin-telegram-bot)
  • Import paths changed for Telegram types
  • Message fields use getters: message.text() instead of message.text

@alexmcgil
alexmcgil requested a review from morfeusys March 3, 2026 10:02
@alexmcgil alexmcgil self-assigned this Mar 3, 2026
@vercel

vercel Bot commented Mar 3, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
jaicf-kotlin Ready Ready Preview, Comment Mar 18, 2026 4:48pm

if (name == null) {
telegram {
name = request.message.chat.firstName ?: request.message.chat.username
name = request.message.senderChat().firstName() ?: request.message.senderChat().username()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why using senderChat instead of chat?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chat() returns MaybeInaccessibleMessage. I was mistaken in thinking it might be unavailable. I've corrected it to use the correct chat() getter.

data class StreamConfig(
val updateIntervalMs: Long = 500,
val initialPlaceholder: String = "...",
val parseMode: ParseMode? = null

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd set it to default ParseMode.Markdown because looks like it's the most widely used case (for LLMs for ex)

*/
data class StreamConfig(
val updateIntervalMs: Long = 500,
val initialPlaceholder: String = "...",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it better to pass here some lambda once it could be multi-language?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, changed to lambda

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