package main import ( "errors" "fmt" "github.com/hamcha/clessy/tg" "github.com/kurrik/witgo/v1/witgo" ) type ClessyHandler struct { } var wit *witgo.Witgo var witHandler ClessyHandler func inittalk() { // Disable if token is not provided if *wittoken == "" { panic(errors.New("No or empty wit token provided (-wit)")) } witgo.NewWitgo(witgo.NewClient(*wittoken), &witHandler) } func talk(broker *tg.Broker, update tg.APIMessage) { } func (h *ClessyHandler) Action(session *witgo.Session, action string) (response *witgo.Session, err error) { response = session response.Context.Set("forecast", "sunny") return } func (h *ClessyHandler) Say(session *witgo.Session, msg string) (response *witgo.Session, err error) { response = session fmt.Printf("< %v\n", msg) return } func (h *ClessyHandler) Merge(session *witgo.Session, entities witgo.EntityMap) (response *witgo.Session, err error) { var ( value string ) response = session if value, err = entities.FirstEntityValue("location"); err != nil { response.Context = witgo.Context{} err = nil } else { response.Context.Merge(witgo.Context{ "loc": value, }) } return } func (h *ClessyHandler) Error(session *witgo.Session, msg string) { }