ALFRED/commands/sponge.go

40 lines
754 B
Go
Raw Permalink Normal View History

2018-07-24 09:59:36 +00:00
/*
* @Author: Bartuccio Antoine
* @Date: 2018-07-24 11:52:11
* @Last Modified by: Bartuccio Antoine
* @Last Modified time: 2019-01-04 10:40:38
2018-07-24 09:59:36 +00:00
*/
package commands
import (
"strings"
"git.klmp200.net/ALFRED/ALFRED/shared"
tb "gopkg.in/tucnak/telebot.v2"
2018-07-24 09:59:36 +00:00
)
func spongify(inputMessage string) string {
spongifiedMessage := ""
for i, char := range inputMessage {
2018-07-24 09:59:36 +00:00
if i%2 == 0 {
spongifiedMessage += strings.ToLower(string(char))
2018-07-24 09:59:36 +00:00
} else {
spongifiedMessage += strings.ToUpper(string(char))
2018-07-24 09:59:36 +00:00
}
}
return spongifiedMessage
}
2018-07-24 09:59:36 +00:00
func Sponge(m *tb.Message) {
message := ""
2020-11-09 18:12:14 +00:00
if m.IsReply() {
message = spongify(m.ReplyTo.Text)
2020-11-09 18:12:14 +00:00
} else {
message = spongify(shared.History.LastMessage(m.Chat.ID))
2020-11-09 18:12:14 +00:00
}
shared.Bot.Send(m.Chat, message)
2018-07-24 09:59:36 +00:00
}