func (this *Misc) Default(name string, msg telegram.TObject, state *map[string]interface{}) { if name == "remind" { if (*state)["remind"] == nil { (*state)["remind"] = msg["text"].(string) this.tg.ReplyToMessage(msg.MessageId(), "How long after now should I remind you?", msg.ChatId()) } else { duration, err := time.ParseDuration(msg["text"].(string)) if err != nil { this.tg.ReplyToMessage(msg.MessageId(), "Invalid time. Supported format: BhCmDsEmsFnsGus", msg.ChatId()) } else { text := (*state)["remind"].(string) this.tg.ReplyToMessage(msg.MessageId(), "Yes, sir!", msg.ChatId()) utils.PostDelayed(func() { if !strings.HasPrefix(text, "\\/") { this.tg.SendMessage("@"+msg.From()["username"].(string)+" "+text, msg.ChatId()) } else { msg["text"] = text[1:] utils.Handler()(msg) } }, duration) utils.ReleaseGrabber(msg.FromId(), msg.ChatId()) } } } }