From f6f17e7a7bbbfeaddf111662dabf8b6f75bb3e79 Mon Sep 17 00:00:00 2001 From: Bartuccio Antoine Date: Wed, 2 Jan 2019 15:46:15 +0100 Subject: [PATCH 1/5] Simplify user chat subscription with a helper --- commands/subscribe.go | 120 ++++++++++++++++++++++++++---------------- 1 file changed, 76 insertions(+), 44 deletions(-) diff --git a/commands/subscribe.go b/commands/subscribe.go index 9bd3600..0c3eba4 100644 --- a/commands/subscribe.go +++ b/commands/subscribe.go @@ -19,6 +19,33 @@ import ( tb "gopkg.in/tucnak/telebot.v2" ) +func getUserSubscribedChats(username string) []int64 { + + serializedSubscriptions, exists := shared.Users.Get(username, "subscribed_chats") + if !exists { + return []int64{} + } + + subscriptions := []int64{} + for _, chatID := range strings.Split(serializedSubscriptions, ":") { + if id, err := strconv.ParseInt(chatID, 10, 64); err == nil { + subscriptions = append(subscriptions, id) + } + } + + return subscriptions +} + +func setUserSubscribedChats(username string, subscriptions []int64) { + + subs := make([]string, len(subscriptions)) + for i, sub := range subscriptions { + subs[i] = strconv.FormatInt(sub, 10) + } + + shared.Users.Set(username, "subscribed_chats", strings.Join(subs, ":")) +} + func getPublishedMessages(chatID int64) []tb.Message { messages := []tb.Message{} @@ -50,6 +77,7 @@ func setPublishedMessages(chatID int64, messages []tb.Message) { // Subscribe user sending the command to the current chat // Command syntax : /subscribe func Subscribe(m *tb.Message) { + if m.Chat.Type != tb.ChatGroup && m.Chat.Type != tb.ChatSuperGroup { shared.Bot.Send(m.Chat, "Cette commande n'est pas autorisée pour ce type de chat") return @@ -60,30 +88,31 @@ func Subscribe(m *tb.Message) { return } - userSubscribedChats, exists := shared.Users.Get(m.Sender.Username, "subscribed_chats") - if !exists { - shared.Bot.Send(m.Chat, "Abonnement au chat : "+m.Chat.Title) - shared.Users.Set(m.Sender.Username, "subscribed_chats", strconv.FormatInt(m.Chat.ID, 10)) - return - } - splittedChats := strings.Split(userSubscribedChats, ":") - for _, chatID := range splittedChats { - if chatID == strconv.FormatInt(m.Chat.ID, 10) { - shared.Bot.Send(m.Chat, "Vous êtes déjà abonné à ce chat : "+m.Chat.Title) - return + subscriptions := getUserSubscribedChats(m.Sender.Username) + alreadySuscribed := false + + for _, sub := range subscriptions { + if sub == m.Chat.ID { + alreadySuscribed = true + break } } - shared.Bot.Send(m.Chat, "Abonnement au chat : "+m.Chat.Title) - if len(userSubscribedChats) != 0 { - shared.Users.Set(m.Sender.Username, "subscribed_chats", userSubscribedChats+":"+strconv.FormatInt(m.Chat.ID, 10)) - } else { - shared.Users.Set(m.Sender.Username, "subscribed_chats", strconv.FormatInt(m.Chat.ID, 10)) + + if alreadySuscribed { + shared.Bot.Send(m.Chat, "Vous êtes déjà abonné à ce chat : "+m.Chat.Title) + return } + + shared.Bot.Send(m.Chat, "Abonnement au chat : "+m.Chat.Title) + subscriptions = append(subscriptions, m.Chat.ID) + + setUserSubscribedChats(m.Sender.Username, subscriptions) } // Unsubscribe user sending the command from the current chat // Command syntax : /unsubscribe func Unsubscribe(m *tb.Message) { + if m.Chat.Type != tb.ChatGroup && m.Chat.Type != tb.ChatSuperGroup { shared.Bot.Send(m.Chat, "Cette commande n'est pas autorisée pour ce type de chat") return @@ -94,20 +123,32 @@ func Unsubscribe(m *tb.Message) { return } - userSubscribedChats, exists := shared.Users.Get(m.Sender.Username, "subscribed_chats") - if !exists || len(userSubscribedChats) == 0 { - shared.Bot.Send(m.Chat, "Vous n'êtes abonné à aucun chat") + subscriptions := getUserSubscribedChats(m.Sender.Username) + + if len(subscriptions) == 0 { + shared.Bot.Send(m.Chat, "Vous n'êtes abonnés à aucun chat") return } - splittedChats := strings.Split(userSubscribedChats, ":") - for i, chatID := range splittedChats { - if chatID == strconv.FormatInt(m.Chat.ID, 10) { - shared.Bot.Send(m.Chat, "désabonnement du chat : "+m.Chat.Title) - splittedChats = append(splittedChats[:i], splittedChats[i+1:]...) - break + + filteredSubscriptions := []int64{} + wasSuscribed := false + + for _, sub := range subscriptions { + if sub == m.Chat.ID { + wasSuscribed = true + continue } + filteredSubscriptions = append(filteredSubscriptions, sub) } - shared.Users.Set(m.Sender.Username, "subscribed_chats", strings.Join(splittedChats, ":")) + + if !wasSuscribed { + shared.Bot.Send(m.Chat, "Vous n'êtes pas abonné au chat : "+m.Chat.Title) + return + } + + shared.Bot.Send(m.Chat, "désabonnement du chat : "+m.Chat.Title) + + setUserSubscribedChats(m.Sender.Username, filteredSubscriptions) } // ListSubscribers List all subscribers of the current chat @@ -204,20 +245,13 @@ func Retrieve(m *tb.Message) { } 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 abonnements") + + if m.Sender.Username == "" { + shared.Bot.Send(m.Chat, "Il faut avoir enregistré un username pour pouvoir utiliser cette fonction") return } - for _, chat := range strings.Split(userSubscribedChats, ":") { - 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 - } - chatList = append(chatList, chatID) - } + chatList = getUserSubscribedChats(m.Sender.Username) } if m.Chat.Type == tb.ChatGroup || m.Chat.Type == tb.ChatSuperGroup { @@ -247,13 +281,11 @@ func Retrieve(m *tb.Message) { func getSubscribers(chatID int64) []string { var subscribers []string for _, username := range shared.Users.GetUsernames() { - userSubscribedChats, exists := shared.Users.Get(username, "subscribed_chats") - if exists { - splittedChats := strings.Split(userSubscribedChats, ":") - for _, splittedChatID := range splittedChats { - if splittedChatID == strconv.FormatInt(chatID, 10) { - subscribers = append(subscribers, username) - } + subscriptions := getUserSubscribedChats(username) + for _, sub := range subscriptions { + if sub == chatID { + subscribers = append(subscribers, username) + break } } } -- 2.40.1 From 019a57e7cf8f76de898eef60bc1df97595927090 Mon Sep 17 00:00:00 2001 From: Bartuccio Antoine Date: Wed, 2 Jan 2019 19:06:47 +0100 Subject: [PATCH 2/5] Use a dedicated struct for user subscriptions --- commands/subscribe.go | 41 ++++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/commands/subscribe.go b/commands/subscribe.go index 0c3eba4..e6c05e7 100644 --- a/commands/subscribe.go +++ b/commands/subscribe.go @@ -19,28 +19,36 @@ import ( tb "gopkg.in/tucnak/telebot.v2" ) -func getUserSubscribedChats(username string) []int64 { +type userSubscription struct { + ChatID int64 + AutoNotify bool +} + +func getUserSubscribedChats(username string) []userSubscription { serializedSubscriptions, exists := shared.Users.Get(username, "subscribed_chats") if !exists { - return []int64{} + return []userSubscription{} } - subscriptions := []int64{} + subscriptions := []userSubscription{} for _, chatID := range strings.Split(serializedSubscriptions, ":") { if id, err := strconv.ParseInt(chatID, 10, 64); err == nil { - subscriptions = append(subscriptions, id) + subscriptions = append(subscriptions, userSubscription{ + ChatID: id, + AutoNotify: true, + }) } } return subscriptions } -func setUserSubscribedChats(username string, subscriptions []int64) { +func setUserSubscribedChats(username string, subscriptions []userSubscription) { subs := make([]string, len(subscriptions)) for i, sub := range subscriptions { - subs[i] = strconv.FormatInt(sub, 10) + subs[i] = strconv.FormatInt(sub.ChatID, 10) } shared.Users.Set(username, "subscribed_chats", strings.Join(subs, ":")) @@ -92,7 +100,7 @@ func Subscribe(m *tb.Message) { alreadySuscribed := false for _, sub := range subscriptions { - if sub == m.Chat.ID { + if sub.ChatID == m.Chat.ID { alreadySuscribed = true break } @@ -104,7 +112,10 @@ func Subscribe(m *tb.Message) { } shared.Bot.Send(m.Chat, "Abonnement au chat : "+m.Chat.Title) - subscriptions = append(subscriptions, m.Chat.ID) + subscriptions = append(subscriptions, userSubscription{ + ChatID: m.Chat.ID, + AutoNotify: true, + }) setUserSubscribedChats(m.Sender.Username, subscriptions) } @@ -130,11 +141,11 @@ func Unsubscribe(m *tb.Message) { return } - filteredSubscriptions := []int64{} + filteredSubscriptions := []userSubscription{} wasSuscribed := false for _, sub := range subscriptions { - if sub == m.Chat.ID { + if sub.ChatID == m.Chat.ID { wasSuscribed = true continue } @@ -236,7 +247,7 @@ 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) { - chatList := []int64{} + chatList := []userSubscription{} hasMessage := false if m.Chat.Type != tb.ChatGroup && m.Chat.Type != tb.ChatSuperGroup && m.Chat.Type != tb.ChatPrivate { @@ -255,13 +266,13 @@ func Retrieve(m *tb.Message) { } if m.Chat.Type == tb.ChatGroup || m.Chat.Type == tb.ChatSuperGroup { - chatList = append(chatList, m.Chat.ID) + chatList = append(chatList, userSubscription{ChatID: m.Chat.ID}) } shared.Bot.Send(m.Chat, "--- Messages publiés ---") - for _, chatID := range chatList { - messages := getPublishedMessages(chatID) + for _, sub := range chatList { + messages := getPublishedMessages(sub.ChatID) if len(messages) > 0 { hasMessage = true } @@ -283,7 +294,7 @@ func getSubscribers(chatID int64) []string { for _, username := range shared.Users.GetUsernames() { subscriptions := getUserSubscribedChats(username) for _, sub := range subscriptions { - if sub == chatID { + if sub.ChatID == chatID { subscribers = append(subscribers, username) break } -- 2.40.1 From dd7a39a158447c10268de9a065d89e34dacb2756 Mon Sep 17 00:00:00 2001 From: Bartuccio Antoine Date: Wed, 2 Jan 2019 19:24:27 +0100 Subject: [PATCH 3/5] Encode auto notify into the user data --- commands/subscribe.go | 39 +++++++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/commands/subscribe.go b/commands/subscribe.go index e6c05e7..9bce285 100644 --- a/commands/subscribe.go +++ b/commands/subscribe.go @@ -24,6 +24,7 @@ type userSubscription struct { AutoNotify bool } +// subscriptions are stored in format ChatID(int64),AutoNotify(bool):ChatID,AutoNotify func getUserSubscribedChats(username string) []userSubscription { serializedSubscriptions, exists := shared.Users.Get(username, "subscribed_chats") @@ -32,13 +33,37 @@ func getUserSubscribedChats(username string) []userSubscription { } subscriptions := []userSubscription{} - for _, chatID := range strings.Split(serializedSubscriptions, ":") { - if id, err := strconv.ParseInt(chatID, 10, 64); err == nil { + for _, sub := range strings.Split(serializedSubscriptions, ":") { + splitedSub := strings.Split(sub, ",") + + // malformated + if len(splitedSub) == 0 { + continue + } + + chatID, err := strconv.ParseInt(splitedSub[0], 10, 64) + if err != nil { + continue + } + + // only ChatID + if len(splitedSub) == 1 { subscriptions = append(subscriptions, userSubscription{ - ChatID: id, + ChatID: chatID, AutoNotify: true, }) + continue } + + autoNotify, err := strconv.ParseBool(splitedSub[1]) + if err != nil { + autoNotify = true + } + + subscriptions = append(subscriptions, userSubscription{ + ChatID: chatID, + AutoNotify: autoNotify, + }) } return subscriptions @@ -48,7 +73,13 @@ func setUserSubscribedChats(username string, subscriptions []userSubscription) { subs := make([]string, len(subscriptions)) for i, sub := range subscriptions { - subs[i] = strconv.FormatInt(sub.ChatID, 10) + subs[i] = strings.Join( + []string{ + strconv.FormatInt(sub.ChatID, 10), + strconv.FormatBool(sub.AutoNotify), + }, + ",", + ) } shared.Users.Set(username, "subscribed_chats", strings.Join(subs, ":")) -- 2.40.1 From a8d8b6d69ef972d53d03c64801fd45220b1d27dc Mon Sep 17 00:00:00 2001 From: Bartuccio Antoine Date: Wed, 2 Jan 2019 23:52:01 +0100 Subject: [PATCH 4/5] Add auto push notification on users when publish is used --- alfred.go | 45 +++++++++++++++------------- commands/register_private.go | 43 ++++++++++++++++++++++++++ commands/subscribe.go | 58 ++++++++++++++++++++++++++++++++++++ doc/publish.md | 13 ++++++-- shared/users.go | 33 ++++++++++++++++++-- 5 files changed, 166 insertions(+), 26 deletions(-) create mode 100644 commands/register_private.go diff --git a/alfred.go b/alfred.go index be6af5b..bfead6d 100644 --- a/alfred.go +++ b/alfred.go @@ -1,8 +1,8 @@ /* * @Author: Bartuccio Antoine * @Date: 2018-07-23 15:24:22 -* @Last Modified by: klmp200 -* @Last Modified time: 2018-11-14 00:33:00 +* @Last Modified by: Bartuccio Antoine +* @Last Modified time: 2019-01-02 22:58:03 */ package main @@ -19,25 +19,28 @@ import ( func main() { registeredCommands := map[string]func(*tb.Message){ - tb.OnText: commands.OnText, - "/hello": commands.Hello, - "/sponge": commands.Sponge, - "/git": commands.Git, - "/framapad": commands.Framapad, - "/setgender": commands.SetGender, - "/gender": commands.Gender, - "/roll": commands.Dice, - "/trump": commands.LastTrumpTweet, - "/trends": commands.TwitterTrends, - "/chaos": commands.TwitterSJW, - "/apero": commands.AperoTime, - "/quote": commands.Quote, - "/subscribe": commands.Subscribe, - "/unsubscribe": commands.Unsubscribe, - "/listsubscribers": commands.ListSubscribers, - "/publish": commands.Publish, - "/unpublish": commands.Unpublish, - "/retrieve": commands.Retrieve, + tb.OnText: commands.OnText, + "/registerprivate": commands.RegisterPrivate, + "/unregisterprivate": commands.UnRegisterPrivate, + "/hello": commands.Hello, + "/sponge": commands.Sponge, + "/git": commands.Git, + "/framapad": commands.Framapad, + "/setgender": commands.SetGender, + "/gender": commands.Gender, + "/roll": commands.Dice, + "/trump": commands.LastTrumpTweet, + "/trends": commands.TwitterTrends, + "/chaos": commands.TwitterSJW, + "/apero": commands.AperoTime, + "/quote": commands.Quote, + "/subscribe": commands.Subscribe, + "/unsubscribe": commands.Unsubscribe, + "/listsubscribers": commands.ListSubscribers, + "/publish": commands.Publish, + "/unpublish": commands.Unpublish, + "/retrieve": commands.Retrieve, + "/toggleupdates": commands.ToggleUpdates, } if err := settings.LoadSettings("settings.json", "settings_custom.json"); err != nil { diff --git a/commands/register_private.go b/commands/register_private.go new file mode 100644 index 0000000..1d807d3 --- /dev/null +++ b/commands/register_private.go @@ -0,0 +1,43 @@ +/* +* @Author: Bartuccio Antoine +* @Date: 2019-01-02 22:46:05 +* @Last Modified by: Bartuccio Antoine +* @Last Modified time: 2019-01-02 22:53:48 + */ + +package commands + +import ( + "../shared" + tb "gopkg.in/tucnak/telebot.v2" +) + +// RegisterPrivate registers an user private chat +func RegisterPrivate(m *tb.Message) { + + if m.Chat.Type != tb.ChatPrivate { + shared.Bot.Send(m.Chat, "Cette commande n'est disponnible qu'en messages privés") + } + + if m.Sender.Username == "" { + shared.Bot.Send(m.Chat, "Vous devez avoir enregistré un username") + } + + shared.Users.SetUserChat(m.Sender.Username, m.Chat) + shared.Bot.Send(m.Chat, "Votre chat privé a bien été enregistré") +} + +// UnRegisterPrivate delete an user private chat +func UnRegisterPrivate(m *tb.Message) { + + if m.Chat.Type != tb.ChatPrivate { + shared.Bot.Send(m.Chat, "Cette commande n'est disponnible qu'en messages privés") + } + + if m.Sender.Username == "" { + shared.Bot.Send(m.Chat, "Vous devez avoir enregistré un username") + } + + shared.Users.SetUserChat(m.Sender.Username, nil) + shared.Bot.Send(m.Chat, "Votre chat privé a bien été supprimé") +} diff --git a/commands/subscribe.go b/commands/subscribe.go index 9bce285..834f3f6 100644 --- a/commands/subscribe.go +++ b/commands/subscribe.go @@ -223,6 +223,7 @@ func Publish(m *tb.Message) { defer shared.Bot.Send(m.Chat, "Message publié : "+m.ReplyTo.Text) savedMessages := getPublishedMessages(m.Chat.ID) setPublishedMessages(m.Chat.ID, append(savedMessages, *m.ReplyTo)) + go pushUpdates(m.Chat.ID, m.ReplyTo) } @@ -319,6 +320,47 @@ func Retrieve(m *tb.Message) { shared.Bot.Send(m.Chat, "--- Messages publiés ---") } +// ToggleUpdates activate/deactivate automatic updates from the chat it's emmited +// Command syntax : /toggleupdates +func ToggleUpdates(m *tb.Message) { + + if m.Chat.Type != tb.ChatGroup && m.Chat.Type != tb.ChatSuperGroup { + shared.Bot.Send(m.Chat, "Cette commande n'est pas autorisée pour ce type de chat") + return + } + + if m.Sender.Username == "" { + shared.Bot.Send(m.Chat, "Il faut avoir enregistré un username pour pouvoir utiliser cette fonction") + return + } + + wasSuscribed := false + subAutoNotify := false + subscriptions := getUserSubscribedChats(m.Sender.Username) + for i, sub := range subscriptions { + if sub.ChatID == m.Chat.ID { + sub.AutoNotify = !sub.AutoNotify + subAutoNotify = sub.AutoNotify + subscriptions[i] = sub + wasSuscribed = true + break + } + } + + if !wasSuscribed { + shared.Bot.Send(m.Chat, "Vous n'êtes pas abonné au chat : "+m.Chat.Title) + return + } + + setUserSubscribedChats(m.Sender.Username, subscriptions) + if subAutoNotify { + shared.Bot.Send(m.Chat, "Les notifications automatiques sont désormais activées pour ce chat") + return + } + shared.Bot.Send(m.Chat, "Les notifications automatiques sont désormais désactivées pour ce chat") + +} + // Get all users subscribed to the provided channel func getSubscribers(chatID int64) []string { var subscribers []string @@ -333,3 +375,19 @@ func getSubscribers(chatID int64) []string { } return subscribers } + +func pushUpdates(chatID int64, message *tb.Message) { + + for _, username := range shared.Users.GetUsernames() { + for _, sub := range getUserSubscribedChats(username) { + if sub.ChatID != chatID || !sub.AutoNotify { + continue + } + chat, err := shared.Users.GetUserChat(username) + if err != nil { + continue + } + shared.Bot.Forward(chat, message) + } + } +} diff --git a/doc/publish.md b/doc/publish.md index 3862db4..b103875 100644 --- a/doc/publish.md +++ b/doc/publish.md @@ -36,7 +36,7 @@ The publish module intend to be a "multi-pin" feature for chats, allowing users ### Publish -**Description** : Publish a message to Alfred for this group chat and sends this message via MP to every subscriber of the group chat. The message can then be retrieved using the *retrieve* command. +**Description** : Publish a message to Alfred for this group chat and sends this message via MP to every subscriber of the group chat if the have not mutted it. The message can then be retrieved using the *retrieve* command. **Usage location** : Group chat only @@ -44,8 +44,6 @@ The publish module intend to be a "multi-pin" feature for chats, allowing users **Command syntax** : /publish -*note* : MP not implemented - ### Unpublish **Description** : Remove a published message from Alfred for this group chat @@ -65,3 +63,12 @@ The publish module intend to be a "multi-pin" feature for chats, allowing users **Command syntax** : /retrieve +### ToggleUpdates + +**Description**: Activate/Deactivate automatic notifications from publish in the group chat where the command is used. By default, this is enabled. + +**Usage location** : Group Chat + +**Command syntax** : /toggleupdates + +**note** : No notification can be send if the user has never done /registerprivate on a private chat with the bot, this is a limitation of the telegram bot API. \ No newline at end of file diff --git a/shared/users.go b/shared/users.go index 7eb47a2..03eaa34 100644 --- a/shared/users.go +++ b/shared/users.go @@ -1,16 +1,19 @@ /* * @Author: Bartuccio Antoine * @Date: 2018-07-24 14:41:03 -* @Last Modified by: klmp200 -* @Last Modified time: 2018-07-24 17:49:51 +* @Last Modified by: Bartuccio Antoine +* @Last Modified time: 2019-01-02 22:37:58 */ package shared import ( "encoding/json" + "fmt" "io/ioutil" "sync" + + tb "gopkg.in/tucnak/telebot.v2" ) type users struct { @@ -23,6 +26,7 @@ type usersFile struct { path string } +// Users shared user for commands var Users users var uf usersFile @@ -72,6 +76,31 @@ func (u users) GetUsernames() []string { return usernames } +// GetUserChat retrieve the chat of the user if registered +func (u users) GetUserChat(username string) (*tb.Chat, error) { + serializedChat, exists := u.Get(username, "private_chat") + if !exists { + return nil, fmt.Errorf("No private chat registered for %s", username) + } + + chat := &tb.Chat{} + if json.Unmarshal([]byte(serializedChat), chat) != nil { + return nil, fmt.Errorf("Error while parsing chat for %s", username) + } + + return chat, nil +} + +// SetUserChat register a private chat for an user +func (u users) SetUserChat(username string, chat *tb.Chat) { + serializedChat, err := json.Marshal(chat) + if err != nil { + return + } + + u.Set(username, "private_chat", string(serializedChat)) +} + func (u usersFile) read() { u.mutex.Lock() defer u.mutex.Unlock() -- 2.40.1 From 41be91c5942872c056fc2a60294571fe030b02ce Mon Sep 17 00:00:00 2001 From: Bartuccio Antoine Date: Wed, 2 Jan 2019 23:40:06 +0100 Subject: [PATCH 5/5] Comments and doc typos --- commands/register_private.go | 6 +++--- commands/subscribe.go | 4 ++-- doc/publish.md | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/commands/register_private.go b/commands/register_private.go index 1d807d3..20a72c9 100644 --- a/commands/register_private.go +++ b/commands/register_private.go @@ -2,7 +2,7 @@ * @Author: Bartuccio Antoine * @Date: 2019-01-02 22:46:05 * @Last Modified by: Bartuccio Antoine -* @Last Modified time: 2019-01-02 22:53:48 +* @Last Modified time: 2019-01-03 00:02:48 */ package commands @@ -16,7 +16,7 @@ import ( func RegisterPrivate(m *tb.Message) { if m.Chat.Type != tb.ChatPrivate { - shared.Bot.Send(m.Chat, "Cette commande n'est disponnible qu'en messages privés") + shared.Bot.Send(m.Chat, "Cette commande n'est disponible qu'en messages privés") } if m.Sender.Username == "" { @@ -31,7 +31,7 @@ func RegisterPrivate(m *tb.Message) { func UnRegisterPrivate(m *tb.Message) { if m.Chat.Type != tb.ChatPrivate { - shared.Bot.Send(m.Chat, "Cette commande n'est disponnible qu'en messages privés") + shared.Bot.Send(m.Chat, "Cette commande n'est disponible qu'en messages privés") } if m.Sender.Username == "" { diff --git a/commands/subscribe.go b/commands/subscribe.go index 834f3f6..44c378b 100644 --- a/commands/subscribe.go +++ b/commands/subscribe.go @@ -320,7 +320,7 @@ func Retrieve(m *tb.Message) { shared.Bot.Send(m.Chat, "--- Messages publiés ---") } -// ToggleUpdates activate/deactivate automatic updates from the chat it's emmited +// ToggleUpdates activate/deactivate automatic updates from the current chat // Command syntax : /toggleupdates func ToggleUpdates(m *tb.Message) { @@ -348,7 +348,7 @@ func ToggleUpdates(m *tb.Message) { } if !wasSuscribed { - shared.Bot.Send(m.Chat, "Vous n'êtes pas abonné au chat : "+m.Chat.Title) + shared.Bot.Send(m.Chat, "Vous n'ête pas abonné au chat : "+m.Chat.Title) return } diff --git a/doc/publish.md b/doc/publish.md index b103875..93dc94f 100644 --- a/doc/publish.md +++ b/doc/publish.md @@ -36,7 +36,7 @@ The publish module intend to be a "multi-pin" feature for chats, allowing users ### Publish -**Description** : Publish a message to Alfred for this group chat and sends this message via MP to every subscriber of the group chat if the have not mutted it. The message can then be retrieved using the *retrieve* command. +**Description** : Publish a message to Alfred for this group chat and sends this message via MP to every subscriber of the group chat if they have not mutted it. The message can then be retrieved using the *retrieve* command. **Usage location** : Group chat only @@ -71,4 +71,4 @@ The publish module intend to be a "multi-pin" feature for chats, allowing users **Command syntax** : /toggleupdates -**note** : No notification can be send if the user has never done /registerprivate on a private chat with the bot, this is a limitation of the telegram bot API. \ No newline at end of file +*note* : No notification can be send if the user has never done /registerprivate on a private chat with the bot, this is a limitation of the telegram bot API. \ No newline at end of file -- 2.40.1