32 lines
805 B
Go
32 lines
805 B
Go
package handler
|
|
|
|
import (
|
|
"context"
|
|
"feishu/client"
|
|
"log"
|
|
|
|
larkapplication "github.com/larksuite/oapi-sdk-go/v3/service/application/v6"
|
|
)
|
|
|
|
var funcMap map[string]func(ctx context.Context, event *larkapplication.P2BotMenuV6) error
|
|
|
|
func P2Handle(ctx context.Context, event *larkapplication.P2BotMenuV6) error {
|
|
if f, ok := funcMap[*event.Event.EventKey]; ok {
|
|
f(ctx, event)
|
|
return nil
|
|
}
|
|
log.Printf("no handler for event: %s", *event.Event.EventKey)
|
|
return nil
|
|
}
|
|
|
|
func init() {
|
|
funcMap = make(map[string]func(ctx context.Context, event *larkapplication.P2BotMenuV6) error)
|
|
funcMap["operation"] = operation
|
|
}
|
|
|
|
func operation(ctx context.Context, event *larkapplication.P2BotMenuV6) error {
|
|
openId := *event.Event.Operator.OperatorId.OpenId
|
|
client.C.SendMsg(openId, "operation")
|
|
return nil
|
|
}
|