mirror of
https://git.klmp200.net/ALFRED/ALFRED.git
synced 2025-01-18 18:46: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
|
package commands
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@ -95,14 +94,14 @@ func Publish(m *tb.Message) {
|
|||||||
defer shared.Bot.Send(m.Chat, "Message publié : "+m.ReplyTo.Text)
|
defer shared.Bot.Send(m.Chat, "Message publié : "+m.ReplyTo.Text)
|
||||||
savedMessages, exists := shared.ChatData.Get(m.Chat.ID, "published_messages")
|
savedMessages, exists := shared.ChatData.Get(m.Chat.ID, "published_messages")
|
||||||
if !exists {
|
if !exists {
|
||||||
messageList := []string{m.ReplyTo.Text}
|
messageList := []tb.Message{*m.ReplyTo}
|
||||||
shared.ChatData.Set(m.Chat.ID, "published_messages", messageList)
|
shared.ChatData.Set(m.Chat.ID, "published_messages", messageList)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
shared.ChatData.Set(
|
shared.ChatData.Set(
|
||||||
m.Chat.ID,
|
m.Chat.ID,
|
||||||
"published_messages",
|
"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
|
// Command syntax : /retrieve
|
||||||
func Retrieve(m *tb.Message) {
|
func Retrieve(m *tb.Message) {
|
||||||
chatList := []int64{}
|
chatList := []int64{}
|
||||||
messageList := []string{}
|
messageList := []tb.Message{}
|
||||||
|
|
||||||
if m.Chat.Type != tb.ChatGroup && m.Chat.Type != tb.ChatSuperGroup && m.Chat.Type != tb.ChatPrivate {
|
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")
|
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 {
|
for _, chatID := range chatList {
|
||||||
if savedMessages, exists := shared.ChatData.Get(chatID, "published_messages"); exists {
|
if savedMessages, exists := shared.ChatData.Get(chatID, "published_messages"); exists {
|
||||||
for _, message := range savedMessages.([]interface{}) {
|
for _, message := range savedMessages.([]interface{}) {
|
||||||
if message, ok := message.(string); ok {
|
if message, ok := message.(tb.Message); ok {
|
||||||
messageList = append(messageList, message)
|
messageList = append(messageList, message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -183,8 +182,8 @@ func Retrieve(m *tb.Message) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
shared.Bot.Send(m.Chat, "--- Messages publiés ---")
|
shared.Bot.Send(m.Chat, "--- Messages publiés ---")
|
||||||
for index, message := range messageList {
|
for _, message := range messageList {
|
||||||
shared.Bot.Send(m.Chat, fmt.Sprintf("%d : %s", index, message))
|
shared.Bot.Forward(m.Chat, &message)
|
||||||
}
|
}
|
||||||
shared.Bot.Send(m.Chat, "--- Messages publiés ---")
|
shared.Bot.Send(m.Chat, "--- Messages publiés ---")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user