ALFRED/commands/sponge.go

40 lines
754 B
Go

/*
* @Author: Bartuccio Antoine
* @Date: 2018-07-24 11:52:11
* @Last Modified by: Bartuccio Antoine
* @Last Modified time: 2019-01-04 10:40:38
*/
package commands
import (
"strings"
"git.klmp200.net/ALFRED/ALFRED/shared"
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) {
message := ""
if m.IsReply() {
message = spongify(m.ReplyTo.Text)
} else {
message = spongify(shared.History.LastMessage(m.Chat.ID))
}
shared.Bot.Send(m.Chat, message)
}