func HandleCalman(message service.Message, service service.Service, cache cache.QueryCache) { if message.UserType() != "user" { return } bot, _ := models.FetchBot(message.GroupID()) // Make sure the message has the bot's name with a preceeding character, and that it isn't escaped index := strings.Index(strings.ToLower(message.Text()), strings.ToLower(bot.BotName)) isEscaped := (index >= 2 && message.Text()[index-2] == '\\') if len(message.Text()) < 1 || index < 1 || isEscaped { return } var ( postString string act models.Action ) if cached := cache.CachedResponse(message.Text()); cached != nil { postString = *cached } else { postString, act = responseForMessage(message, bot) } postString = updatedPostText(act, postString) postString = utility.ProcessedString(postString) cacheID := cache.CacheQuery(message.Text(), postString) fmt.Printf("Query: %v\n", message.Text()) if postString != "" { fmt.Printf("Action: %v\n", act.Content) fmt.Printf("Posting: %v\n", postString) service.PostText(bot.Key, postString, cacheID, message) } }