mirror of
https://git.klmp200.net/ALFRED/ALFRED.git
synced 2025-01-18 10:36:44 +01:00
Save message instead of message text for subscriptions
This commit is contained in:
parent
7edc83f003
commit
7ffb5a4a2a
@ -11,7 +11,6 @@
|
||||
package commands
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
@ -95,14 +94,14 @@ func Publish(m *tb.Message) {
|
||||
defer shared.Bot.Send(m.Chat, "Message publié : "+m.ReplyTo.Text)
|
||||
savedMessages, exists := shared.ChatData.Get(m.Chat.ID, "published_messages")
|
||||
if !exists {
|
||||
messageList := []string{m.ReplyTo.Text}
|
||||
messageList := []tb.Message{*m.ReplyTo}
|
||||
shared.ChatData.Set(m.Chat.ID, "published_messages", messageList)
|
||||
return
|
||||
}
|
||||
shared.ChatData.Set(
|
||||
m.Chat.ID,
|
||||
"published_messages",
|
||||
append(savedMessages.([]interface{}), m.ReplyTo.Text),
|
||||
append(savedMessages.([]interface{}), *m.ReplyTo),
|
||||
)
|
||||
|
||||
}
|
||||
@ -139,7 +138,7 @@ func Unpublish(m *tb.Message) {
|
||||
// Command syntax : /retrieve
|
||||
func Retrieve(m *tb.Message) {
|
||||
chatList := []int64{}
|
||||
messageList := []string{}
|
||||
messageList := []tb.Message{}
|
||||
|
||||
if m.Chat.Type != tb.ChatGroup && m.Chat.Type != tb.ChatSuperGroup && m.Chat.Type != tb.ChatPrivate {
|
||||
shared.Bot.Send(m.Chat, "Cette commande n'est pas autorisée pour ce type de chat")
|
||||
@ -170,7 +169,7 @@ func Retrieve(m *tb.Message) {
|
||||
for _, chatID := range chatList {
|
||||
if savedMessages, exists := shared.ChatData.Get(chatID, "published_messages"); exists {
|
||||
for _, message := range savedMessages.([]interface{}) {
|
||||
if message, ok := message.(string); ok {
|
||||
if message, ok := message.(tb.Message); ok {
|
||||
messageList = append(messageList, message)
|
||||
}
|
||||
}
|
||||
@ -183,8 +182,8 @@ func Retrieve(m *tb.Message) {
|
||||
}
|
||||
|
||||
shared.Bot.Send(m.Chat, "--- Messages publiés ---")
|
||||
for index, message := range messageList {
|
||||
shared.Bot.Send(m.Chat, fmt.Sprintf("%d : %s", index, message))
|
||||
for _, message := range messageList {
|
||||
shared.Bot.Forward(m.Chat, &message)
|
||||
}
|
||||
shared.Bot.Send(m.Chat, "--- Messages publiés ---")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user