2017-11-18 13:06:20 +00:00
|
|
|
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
|
2020-05-21 09:02:35 +00:00
|
|
|
// edited with, say two columns: msg_id,chat_id
|
2017-11-18 13:06:20 +00:00
|
|
|
// could easily implement MessageSig() making
|
|
|
|
// instances of stored messages editable.
|
|
|
|
type Editable interface {
|
2017-11-19 15:16:39 +00:00
|
|
|
// MessageSig is a "message signature".
|
|
|
|
//
|
|
|
|
// For inline messages, return chatID = 0.
|
2017-12-26 22:39:15 +00:00
|
|
|
MessageSig() (messageID string, chatID int64)
|
2017-11-18 13:06:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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 {
|
2017-12-26 22:39:15 +00:00
|
|
|
MessageID string `sql:"message_id" json:"message_id"`
|
|
|
|
ChatID int64 `sql:"chat_id" json:"chat_id"`
|
2017-11-18 13:06:20 +00:00
|
|
|
}
|
|
|
|
|
2017-12-26 22:39:15 +00:00
|
|
|
func (x StoredMessage) MessageSig() (string, int64) {
|
2017-11-18 13:06:20 +00:00
|
|
|
return x.MessageID, x.ChatID
|
|
|
|
}
|