fix: убран префикс tg:// из chat_id при отправке (chat not found); тесты проверяют ChatID
All checks were successful
CI / test (push) Successful in 54s
CI / build-and-package (amd64, darwin) (push) Successful in 45s
CI / build-and-package (amd64, linux) (push) Successful in 46s
CI / build-and-package (amd64, windows) (push) Successful in 46s
CI / build-and-package (arm64, darwin) (push) Successful in 44s
CI / build-and-package (arm64, linux) (push) Successful in 47s

This commit is contained in:
Hermes
2026-08-16 00:19:49 +05:00
parent 005877bfc5
commit 7be75fe14f
2 changed files with 9 additions and 1 deletions

View File

@@ -14,6 +14,7 @@ import (
"log"
"net/http"
"strconv"
"strings"
"time"
"github.com/kamelion/ratatoskr-go/internal/chat"
@@ -71,8 +72,12 @@ func (ch *Channel) Run(ctx context.Context) error {
}
}
// tgPrefix — префикс адреса чата в ratatoskr (см. handleUpdate).
// В Bot API chat_id передаётся без него.
const tgPrefix = "tg://"
func (ch *Channel) Send(_ context.Context, to chat.Address, m chat.Message) error {
return ch.sendMsg(string(to), formatOutgoing(m))
return ch.sendMsg(strings.TrimPrefix(string(to), tgPrefix), formatOutgoing(m))
}
func (ch *Channel) Ask(_ context.Context, to chat.Address, m chat.Message) error {

View File

@@ -79,6 +79,9 @@ func TestSend(t *testing.T) {
if len(f.sent) != 1 {
t.Fatal("не отправлено")
}
if f.sent[0].ChatID != "123" {
t.Errorf("chat_id = %q, want 123 (без префикса tg://)", f.sent[0].ChatID)
}
if f.sent[0].Text != "hello" {
t.Errorf("text = %q", f.sent[0].Text)
}