-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcontext.go
33 lines (29 loc) · 971 Bytes
/
context.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package neocortex
import (
"context"
"fmt"
)
// PersonInfo describes the basic info of the person
type PersonInfo struct {
ID string `json:"id"`
Timezone string `json:"timezone"`
Picture string `json:"picture"`
Locale string `json:"locale"`
Name string `json:"name"`
}
// Context represent the context of a conversation
type Context struct {
Context *context.Context `json:"-" bson:"-"`
SessionID string `json:"session_id" bson:"session_id"`
Person PersonInfo `json:"person" bson:"person"`
Variables map[string]interface{} `json:"variables" bson:"variables"`
}
func (c *Context) String() string {
s := "\n===== CONTEXT =====\n"
s = s + fmt.Sprintf("session: %s\n", c.SessionID)
s = s + fmt.Sprintf("context: %v\n", c.Context)
s = s + fmt.Sprintf("user name: %s\n", c.Person.Name)
s = s + fmt.Sprintf("total context variables: %d\n", len(c.Variables))
s = s + "======================\n"
return s
}