diff --git a/commands/sponge.go b/commands/sponge.go index ff3a1eb..8d65bd4 100644 --- a/commands/sponge.go +++ b/commands/sponge.go @@ -15,15 +15,25 @@ 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(inputMessage string) string { + spongifiedMessage := "" + for i, char := range inputMessage { if i%2 == 0 { - message += strings.ToLower(string(char)) + spongifiedMessage += strings.ToLower(string(char)) } else { - message += strings.ToUpper(string(char)) + spongifiedMessage += strings.ToUpper(string(char)) } } - shared.Bot.Send(m.Chat, message) - + return spongifiedMessage } + +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) +} +