From 9df38b5a8887ca3eb2c1de76b10eae7c1c48275e Mon Sep 17 00:00:00 2001 From: madahin Date: Mon, 9 Nov 2020 18:40:30 +0100 Subject: [PATCH] Calling the /sponge command as a reply will now spongify the quoted message --- commands/sponge.go | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/commands/sponge.go b/commands/sponge.go index ff3a1eb..c1156b6 100644 --- a/commands/sponge.go +++ b/commands/sponge.go @@ -15,15 +15,24 @@ import ( tb "gopkg.in/tucnak/telebot.v2" ) -func Sponge(m *tb.Message) { - message := "" - for i, char := range shared.History.LastMessage(m.Chat.ID) { +func Spongify(input_message string) string { + spongified_message := "" + for i, char := range input_message { if i%2 == 0 { - message += strings.ToLower(string(char)) + spongified_message += strings.ToLower(string(char)) } else { - message += strings.ToUpper(string(char)) + spongified_message += strings.ToUpper(string(char)) } } - shared.Bot.Send(m.Chat, message) - + return spongified_message +} + +func Sponge(m *tb.Message) { + message := "" + if m.IsReply() { + message = Spongify(m.ReplyTo.Text) + } else { + message = Spongify(shared.History.LastMessage(m.Chat.ID)) + } + shared.Bot.Send(m.Chat, message) }