From 9df38b5a8887ca3eb2c1de76b10eae7c1c48275e Mon Sep 17 00:00:00 2001 From: madahin Date: Mon, 9 Nov 2020 18:40:30 +0100 Subject: [PATCH 1/4] 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) } From e786b77f627c6d2fed130dde25e44b131a22194c Mon Sep 17 00:00:00 2001 From: madahin Date: Mon, 9 Nov 2020 19:12:14 +0100 Subject: [PATCH 2/4] Fix identation --- commands/sponge.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/commands/sponge.go b/commands/sponge.go index c1156b6..f1a594a 100644 --- a/commands/sponge.go +++ b/commands/sponge.go @@ -29,10 +29,10 @@ func Spongify(input_message string) string { 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) + if m.IsReply() { + message = Spongify(m.ReplyTo.Text) + } else { + message = Spongify(shared.History.LastMessage(m.Chat.ID)) + } + shared.Bot.Send(m.Chat, message) } From 30397b92075dad121e4a6bcd63601e0591bb5688 Mon Sep 17 00:00:00 2001 From: madahin Date: Mon, 9 Nov 2020 19:14:21 +0100 Subject: [PATCH 3/4] Fix formating with `go fmt` --- commands/sponge.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/commands/sponge.go b/commands/sponge.go index f1a594a..5ba5461 100644 --- a/commands/sponge.go +++ b/commands/sponge.go @@ -16,7 +16,7 @@ import ( ) func Spongify(input_message string) string { - spongified_message := "" + spongified_message := "" for i, char := range input_message { if i%2 == 0 { spongified_message += strings.ToLower(string(char)) @@ -24,7 +24,7 @@ func Spongify(input_message string) string { spongified_message += strings.ToUpper(string(char)) } } - return spongified_message + return spongified_message } func Sponge(m *tb.Message) { From 7b4f2d3b258259ff6a4b41b8293551e630471c95 Mon Sep 17 00:00:00 2001 From: madahin Date: Mon, 9 Nov 2020 19:24:22 +0100 Subject: [PATCH 4/4] Use camelCase instead of snake_case Because this shity language can't deal with snake_case and the snake_case evangile is a traitor to it's cause. --- commands/sponge.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/commands/sponge.go b/commands/sponge.go index 5ba5461..8d65bd4 100644 --- a/commands/sponge.go +++ b/commands/sponge.go @@ -15,24 +15,25 @@ import ( tb "gopkg.in/tucnak/telebot.v2" ) -func Spongify(input_message string) string { - spongified_message := "" - for i, char := range input_message { +func spongify(inputMessage string) string { + spongifiedMessage := "" + for i, char := range inputMessage { if i%2 == 0 { - spongified_message += strings.ToLower(string(char)) + spongifiedMessage += strings.ToLower(string(char)) } else { - spongified_message += strings.ToUpper(string(char)) + spongifiedMessage += strings.ToUpper(string(char)) } } - return spongified_message + return spongifiedMessage } func Sponge(m *tb.Message) { message := "" if m.IsReply() { - message = Spongify(m.ReplyTo.Text) + message = spongify(m.ReplyTo.Text) } else { - message = Spongify(shared.History.LastMessage(m.Chat.ID)) + message = spongify(shared.History.LastMessage(m.Chat.ID)) } shared.Bot.Send(m.Chat, message) } +