Merge pull request 'spongify_answer' (#19) from spongify_answer into master

Reviewed-on: https://git.klmp200.net/ALFRED/ALFRED/pulls/19
This commit is contained in:
Antoine Bartuccio 2020-11-09 18:29:45 +00:00
commit 7b26cc3640
1 changed files with 17 additions and 7 deletions

View File

@ -15,15 +15,25 @@ import (
tb "gopkg.in/tucnak/telebot.v2" tb "gopkg.in/tucnak/telebot.v2"
) )
func spongify(inputMessage string) string {
spongifiedMessage := ""
for i, char := range inputMessage {
if i%2 == 0 {
spongifiedMessage += strings.ToLower(string(char))
} else {
spongifiedMessage += strings.ToUpper(string(char))
}
}
return spongifiedMessage
}
func Sponge(m *tb.Message) { func Sponge(m *tb.Message) {
message := "" message := ""
for i, char := range shared.History.LastMessage(m.Chat.ID) { if m.IsReply() {
if i%2 == 0 { message = spongify(m.ReplyTo.Text)
message += strings.ToLower(string(char))
} else { } else {
message += strings.ToUpper(string(char)) message = spongify(shared.History.LastMessage(m.Chat.ID))
}
} }
shared.Bot.Send(m.Chat, message) shared.Bot.Send(m.Chat, message)
} }