From 7be75fe14f2e182d3bb999ebe3cc0ec6f0575866 Mon Sep 17 00:00:00 2001 From: Hermes Date: Sun, 16 Aug 2026 00:19:49 +0500 Subject: [PATCH] =?UTF-8?q?fix:=20=D1=83=D0=B1=D1=80=D0=B0=D0=BD=20=D0=BF?= =?UTF-8?q?=D1=80=D0=B5=D1=84=D0=B8=D0=BA=D1=81=20tg://=20=D0=B8=D0=B7=20c?= =?UTF-8?q?hat=5Fid=20=D0=BF=D1=80=D0=B8=20=D0=BE=D1=82=D0=BF=D1=80=D0=B0?= =?UTF-8?q?=D0=B2=D0=BA=D0=B5=20(chat=20not=20found);=20=D1=82=D0=B5=D1=81?= =?UTF-8?q?=D1=82=D1=8B=20=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D1=8F=D1=8E?= =?UTF-8?q?=D1=82=20ChatID?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/chat/telegram/telegram.go | 7 ++++++- internal/chat/telegram/telegram_test.go | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/internal/chat/telegram/telegram.go b/internal/chat/telegram/telegram.go index 71ab677..072f907 100644 --- a/internal/chat/telegram/telegram.go +++ b/internal/chat/telegram/telegram.go @@ -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 { diff --git a/internal/chat/telegram/telegram_test.go b/internal/chat/telegram/telegram_test.go index 679637a..dd814e1 100644 --- a/internal/chat/telegram/telegram_test.go +++ b/internal/chat/telegram/telegram_test.go @@ -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) }