2018-07-24 11:59:36 +02:00
|
|
|
/*
|
|
|
|
* @Author: Bartuccio Antoine
|
|
|
|
* @Date: 2018-07-24 11:52:11
|
2019-01-04 10:55:51 +01:00
|
|
|
* @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"
|
2019-01-04 10:55:51 +01:00
|
|
|
|
|
|
|
"git.klmp200.net/ALFRED/ALFRED/shared"
|
|
|
|
|
|
|
|
tb "gopkg.in/tucnak/telebot.v2"
|
2018-07-24 11:59:36 +02:00
|
|
|
)
|
|
|
|
|
2020-11-09 19:24:22 +01:00
|
|
|
func spongify(inputMessage string) string {
|
|
|
|
spongifiedMessage := ""
|
|
|
|
for i, char := range inputMessage {
|
2018-07-24 11:59:36 +02:00
|
|
|
if i%2 == 0 {
|
2020-11-09 19:24:22 +01:00
|
|
|
spongifiedMessage += strings.ToLower(string(char))
|
2018-07-24 11:59:36 +02:00
|
|
|
} else {
|
2020-11-09 19:24:22 +01:00
|
|
|
spongifiedMessage += strings.ToUpper(string(char))
|
2018-07-24 11:59:36 +02:00
|
|
|
}
|
|
|
|
}
|
2020-11-09 19:24:22 +01:00
|
|
|
return spongifiedMessage
|
2020-11-09 18:40:30 +01:00
|
|
|
}
|
2018-07-24 11:59:36 +02:00
|
|
|
|
2020-11-09 18:40:30 +01:00
|
|
|
func Sponge(m *tb.Message) {
|
|
|
|
message := ""
|
2020-11-09 19:12:14 +01:00
|
|
|
if m.IsReply() {
|
2020-11-09 19:24:22 +01:00
|
|
|
message = spongify(m.ReplyTo.Text)
|
2020-11-09 19:12:14 +01:00
|
|
|
} else {
|
2020-11-09 19:24:22 +01:00
|
|
|
message = spongify(shared.History.LastMessage(m.Chat.ID))
|
2020-11-09 19:12:14 +01:00
|
|
|
}
|
|
|
|
shared.Bot.Send(m.Chat, message)
|
2018-07-24 11:59:36 +02:00
|
|
|
}
|
2020-11-09 19:24:22 +01:00
|
|
|
|