-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstate.go
More file actions
33 lines (27 loc) · 712 Bytes
/
state.go
File metadata and controls
33 lines (27 loc) · 712 Bytes
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 tim
import (
"fmt"
"github.com/labstack/echo/v4"
)
func StateChange(req Req, c echo.Context) error {
fmt.Println(req.CallbackCommand)
return nil
}
type StateInfo struct {
CallbackCommand string `json:"CallbackCommand"`
Info struct {
Action string `json:"Action"`
ToAccount string `json:"To_Account"`
Reason string `json:"Reason"`
} `json:"Info,omitempty"`
}
type StateCallBack func(req Req, info StateInfo) error
func (s IMServer) CallbackStateChange(commandFunc StateCallBack) {
AddCommandFuc(StateStateChange, func(req Req, c echo.Context) error {
var info StateInfo
if err := c.Bind(&info); err != nil {
return err
}
return commandFunc(req, info)
})
}