TG settlement service

This commit is contained in:
Stephan D
2026-01-02 14:54:18 +01:00
parent ea1c69f14a
commit 743f683d92
82 changed files with 4693 additions and 503 deletions

View File

@@ -0,0 +1,50 @@
package telegram
import (
"strconv"
"github.com/tech/sendico/pkg/model"
)
type Update struct {
UpdateID int64 `json:"update_id"`
Message *Message `json:"message,omitempty"`
}
type Message struct {
MessageID int64 `json:"message_id"`
Date int64 `json:"date,omitempty"`
Chat Chat `json:"chat"`
From *User `json:"from,omitempty"`
Text string `json:"text,omitempty"`
ReplyToMessage *Message `json:"reply_to_message,omitempty"`
}
type Chat struct {
ID int64 `json:"id"`
}
type User struct {
ID int64 `json:"id"`
Username string `json:"username,omitempty"`
}
func (m *Message) ToModel() *model.TelegramMessage {
if m == nil {
return nil
}
result := &model.TelegramMessage{
ChatID: strconv.FormatInt(m.Chat.ID, 10),
MessageID: strconv.FormatInt(m.MessageID, 10),
Text: m.Text,
SentAt: m.Date,
}
if m.From != nil {
result.FromUserID = strconv.FormatInt(m.From.ID, 10)
result.FromUsername = m.From.Username
}
if m.ReplyToMessage != nil {
result.ReplyToMessageID = strconv.FormatInt(m.ReplyToMessage.MessageID, 10)
}
return result
}