31 lines
984 B
Go
31 lines
984 B
Go
package telebot
|
|
|
|
// Editable is an interface for all objects that
|
|
// provide "message signature", a pair of 32-bit
|
|
// message ID and 64-bit chat ID, both required
|
|
// for edit operations.
|
|
//
|
|
// Use case: DB model struct for messages to-be
|
|
// edited with, say two columns: msg_id,chat_id
|
|
// could easily implement MessageSig() making
|
|
// instances of stored messages editable.
|
|
type Editable interface {
|
|
// MessageSig is a "message signature".
|
|
//
|
|
// For inline messages, return chatID = 0.
|
|
MessageSig() (messageID string, chatID int64)
|
|
}
|
|
|
|
// StoredMessage is an example struct suitable for being
|
|
// stored in the database as-is or being embedded into
|
|
// a larger struct, which is often the case (you might
|
|
// want to store some metadata alongside, or might not.)
|
|
type StoredMessage struct {
|
|
MessageID string `sql:"message_id" json:"message_id"`
|
|
ChatID int64 `sql:"chat_id" json:"chat_id"`
|
|
}
|
|
|
|
func (x StoredMessage) MessageSig() (string, int64) {
|
|
return x.MessageID, x.ChatID
|
|
}
|