ALFRED/commands/sponge.go

39 lines
765 B
Go
Raw Normal View History

2018-07-24 11:59:36 +02: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 11:59:36 +02:00
*/
package commands
import (
"strings"
"git.klmp200.net/ALFRED/ALFRED/shared"
tb "gopkg.in/tucnak/telebot.v2"
2018-07-24 11:59:36 +02:00
)
func Spongify(input_message string) string {
spongified_message := ""
for i, char := range input_message {
2018-07-24 11:59:36 +02:00
if i%2 == 0 {
spongified_message += strings.ToLower(string(char))
2018-07-24 11:59:36 +02:00
} else {
spongified_message += strings.ToUpper(string(char))
2018-07-24 11:59:36 +02:00
}
}
return spongified_message
}
2018-07-24 11:59:36 +02:00
func Sponge(m *tb.Message) {
message := ""
2020-11-09 19:12:14 +01:00
if m.IsReply() {
message = Spongify(m.ReplyTo.Text)
} else {
message = Spongify(shared.History.LastMessage(m.Chat.ID))
}
shared.Bot.Send(m.Chat, message)
2018-07-24 11:59:36 +02:00
}