From 903e0daad16c8302f9ad83714a5f4e2091f55acd Mon Sep 17 00:00:00 2001 From: klmp200 Date: Tue, 24 Jul 2018 02:34:55 +0200 Subject: [PATCH] Add sponge --- alfred.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/alfred.go b/alfred.go index 80f866e..39f3709 100644 --- a/alfred.go +++ b/alfred.go @@ -2,7 +2,7 @@ * @Author: Bartuccio Antoine * @Date: 2018-07-23 15:24:22 * @Last Modified by: klmp200 -* @Last Modified time: 2018-07-24 02:25:26 +* @Last Modified time: 2018-07-24 02:33:57 */ package main @@ -12,6 +12,7 @@ import ( "./shared" tb "gopkg.in/tucnak/telebot.v2" "log" + "strings" "time" ) @@ -41,6 +42,19 @@ func main() { shared.History.AddMessage(m.Chat.ID, m.Text) }) + b.Handle("/sponge", func(m *tb.Message) { + message := "" + for i, char := range shared.History.LastMessage(m.Chat.ID) { + if i%2 == 0 { + message += strings.ToLower(string(char)) + } else { + message += strings.ToUpper(string(char)) + } + } + b.Send(m.Chat, message) + + }) + log.Println("Starting bot") b.Start() }