mirror of
https://git.klmp200.net/ALFRED/ALFRED.git
synced 2025-01-18 10:36:44 +01:00
Merge branch 'bro-features' of ALFRED/ALFRED into master
This commit is contained in:
commit
02db29beae
@ -1,4 +1,4 @@
|
||||
FROM golang:1.10 AS builder
|
||||
FROM golang:1.11 AS builder
|
||||
|
||||
# Download and install the latest release of dep
|
||||
# ADD https://github.com/golang/dep/releases/download/v0.4.1/dep-linux-amd64 /usr/bin/dep
|
||||
|
@ -22,7 +22,7 @@ import (
|
||||
// Subscribe user sending the command to the current chat
|
||||
// Command syntax : /subscribe
|
||||
func Subscribe(m *tb.Message) {
|
||||
if m.Chat.Type != "group" && m.Chat.Type != "supergroup" {
|
||||
if m.Chat.Type != tb.ChatGroup && m.Chat.Type != tb.ChatSuperGroup {
|
||||
shared.Bot.Send(m.Chat, "Cette commande n'est pas authorisée pour ce type de chat")
|
||||
return
|
||||
}
|
||||
@ -50,7 +50,7 @@ func Subscribe(m *tb.Message) {
|
||||
// Unsubscribe user sending the command from the current chat
|
||||
// Command syntax : /unsubscribe
|
||||
func Unsubscribe(m *tb.Message) {
|
||||
if m.Chat.Type != "group" && m.Chat.Type != "supergroup" {
|
||||
if m.Chat.Type != tb.ChatGroup && m.Chat.Type != tb.ChatSuperGroup {
|
||||
shared.Bot.Send(m.Chat, "Cette commande n'est pas authorisée pour ce type de chat")
|
||||
return
|
||||
}
|
||||
@ -73,7 +73,7 @@ func Unsubscribe(m *tb.Message) {
|
||||
// ListSubscribers List all subscribers of the current chat
|
||||
// Command syntax : /listsubscribers
|
||||
func ListSubscribers(m *tb.Message) {
|
||||
if m.Chat.Type != "group" && m.Chat.Type != "supergroup" {
|
||||
if m.Chat.Type != tb.ChatGroup && m.Chat.Type != tb.ChatSuperGroup {
|
||||
shared.Bot.Send(m.Chat, "Cette commande n'est pas authorisée pour ce type de chat")
|
||||
return
|
||||
}
|
||||
@ -99,8 +99,11 @@ func Publish(m *tb.Message) {
|
||||
shared.ChatData.Set(m.Chat.ID, "published_messages", messageList)
|
||||
return
|
||||
}
|
||||
shared.ChatData.Set(m.Chat.ID, "published_messages",
|
||||
append(savedMessages.([]interface{}), m.ReplyTo.Text))
|
||||
shared.ChatData.Set(
|
||||
m.Chat.ID,
|
||||
"published_messages",
|
||||
append(savedMessages.([]interface{}), m.ReplyTo.Text),
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
@ -135,38 +138,55 @@ func Unpublish(m *tb.Message) {
|
||||
// If performed in Group Chat : retrieved all published messages for this chat
|
||||
// Command syntax : /retrieve
|
||||
func Retrieve(m *tb.Message) {
|
||||
if m.Chat.Type == "group" || m.Chat.Type == "supergroup" {
|
||||
savedMessages, exists := shared.ChatData.Get(m.Chat.ID, "published_messages")
|
||||
fmt.Println(savedMessages)
|
||||
if !exists || len(savedMessages.([]interface{})) == 0 {
|
||||
shared.Bot.Send(m.Chat, "Aucun message publié")
|
||||
return
|
||||
}
|
||||
shared.Bot.Send(m.Chat, "--- Messages publiés ---")
|
||||
for index, message := range savedMessages.([]interface{}) {
|
||||
shared.Bot.Send(m.Chat, strconv.Itoa(index)+" : "+message.(string))
|
||||
}
|
||||
shared.Bot.Send(m.Chat, "--- Messages publiés ---")
|
||||
chatList := []int64{}
|
||||
messageList := []string{}
|
||||
|
||||
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")
|
||||
return
|
||||
}
|
||||
if m.Chat.Type == "private" {
|
||||
|
||||
if m.Chat.Type == tb.ChatPrivate {
|
||||
userSubscribedChats, exists := shared.Users.Get(m.Sender.Username, "subscribed_chats")
|
||||
if !exists || len(userSubscribedChats) == 0 {
|
||||
shared.Bot.Send(m.Chat, "Aucun abonnement")
|
||||
shared.Bot.Send(m.Chat, "Aucun abonnements")
|
||||
return
|
||||
}
|
||||
|
||||
for _, chat := range strings.Split(userSubscribedChats, ":") {
|
||||
chatID, _ := strconv.ParseInt(chat, 10, 64)
|
||||
savedMessages, _ := shared.ChatData.Get(chatID, "published_messages")
|
||||
shared.Bot.Send(m.Chat, "--- Messages publiés ---")
|
||||
for index, message := range savedMessages.([]interface{}) {
|
||||
shared.Bot.Send(m.Chat, strconv.Itoa(index)+" : "+message.(string))
|
||||
chatID, err := strconv.ParseInt(chat, 10, 64)
|
||||
if err != nil {
|
||||
shared.Bot.Send(m.Chat, "Erreur lors de la récupération de vos évènements")
|
||||
return
|
||||
}
|
||||
shared.Bot.Send(m.Chat, "--- Messages publiés ---")
|
||||
chatList = append(chatList, chatID)
|
||||
}
|
||||
}
|
||||
|
||||
if m.Chat.Type == tb.ChatGroup || m.Chat.Type == tb.ChatSuperGroup {
|
||||
chatList = append(chatList, m.Chat.ID)
|
||||
}
|
||||
|
||||
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 {
|
||||
messageList = append(messageList, message)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if len(messageList) == 0 {
|
||||
shared.Bot.Send(m.Chat, "Aucun message publié")
|
||||
return
|
||||
}
|
||||
shared.Bot.Send(m.Chat, "Cette commande n'est pas autorisée pour ce type de chat")
|
||||
|
||||
shared.Bot.Send(m.Chat, "--- Messages publiés ---")
|
||||
for index, message := range messageList {
|
||||
shared.Bot.Send(m.Chat, fmt.Sprintf("%d : %s", index, message))
|
||||
}
|
||||
shared.Bot.Send(m.Chat, "--- Messages publiés ---")
|
||||
}
|
||||
|
||||
// Get all users subscribed to the provided channel
|
||||
|
Loading…
Reference in New Issue
Block a user