feat(telegram): optional resume (#104)

This commit is contained in:
banteg
2026-01-12 19:59:25 +04:00
committed by GitHub
parent 98ba41f8c7
commit 2f9787ac27
8 changed files with 123 additions and 22 deletions
+5 -5
View File
@@ -48,6 +48,7 @@ line. If you want auto-resume without replies, enable chat sessions.
Configuration (under `[transports.telegram]`):
```toml
show_resume_line = true # set false to hide resume lines
session_mode = "chat" # or "stateless"
```
@@ -59,6 +60,10 @@ Behavior:
State is stored in `telegram_chat_sessions_state.json` alongside the config file.
Set `show_resume_line = false` to hide resume lines when takopi can auto-resume
(topics or chat sessions) and a project context is resolved. Otherwise the resume
line stays visible so reply-to-continue still works.
## Message overflow
By default, takopi trims long final responses to ~3500 characters to stay under
@@ -84,7 +89,6 @@ Configuration (under `[transports.telegram]`):
[transports.telegram.topics]
enabled = true
scope = "auto" # auto | main | projects | all
show_resume_line = true
```
Requirements:
@@ -96,10 +100,6 @@ Requirements:
- `auto`: if any project chats are configured, uses `projects`; otherwise `main`.
- The bot needs the **Manage Topics** permission in the relevant chat(s).
Optional:
- `show_resume_line`: set `false` to hide the resume command line in topic threads.
Commands:
- `main`: `/topic <project> @branch` creates a topic in the main chat and binds it.
+5 -6
View File
@@ -39,6 +39,8 @@ To continue a session:
- **Chat sessions** (optional) store one resume token per chat (per sender in groups) so new messages
auto-resume without replying. Enable with `session_mode = "chat"` and reset with `/new`.
State is stored in `telegram_chat_sessions_state.json`.
You can hide resume lines by setting `[transports.telegram].show_resume_line = false`
when auto-resume is available and a project context is resolved.
Reply-to-continue always works, even if chat sessions or topics are enabled.
@@ -262,7 +264,6 @@ Topics bind Telegram forum threads to specific project/branch contexts. They als
```toml
[transports.telegram.topics]
enabled = true
# show_resume_line = false
```
Your bot needs **Manage Topics** permission in the group.
@@ -270,8 +271,6 @@ Your bot needs **Manage Topics** permission in the group.
If any `projects.<alias>.chat_id` are configured, topics are managed in those
project chats; otherwise topics are managed in the main chat.
Set `show_resume_line = false` to hide the resume command line in topic threads.
### Topic behavior
```
@@ -321,10 +320,10 @@ In project chats, omit the project: `/topic @branch` or `/ctx set @branch`.
```toml
[transports.telegram]
chat_id = -1001234567890
# show_resume_line = false
[transports.telegram.topics]
enabled = true
# show_resume_line = false
```
**Project chats:**
@@ -332,10 +331,10 @@ enabled = true
```toml
[transports.telegram]
chat_id = 123456789 # main chat (private, for non-project messages)
# show_resume_line = false
[transports.telegram.topics]
enabled = true
# show_resume_line = false
[projects.takopi]
path = "~/dev/takopi"
@@ -448,6 +447,7 @@ chat_id = 123456789
voice_transcription = true
voice_transcription_model = "gpt-4o-mini-transcribe"
session_mode = "stateless" # or "chat" for auto-resume per chat
show_resume_line = true
[transports.telegram.files]
enabled = true
@@ -460,7 +460,6 @@ deny_globs = [".git/**", ".env", ".envrc", "**/*.pem", "**/.ssh/**"]
[transports.telegram.topics]
enabled = true
scope = "auto"
show_resume_line = true
# Project definitions
[projects.takopi]