This commit is contained in:
cdle
2023-06-12 12:07:12 +08:00
parent 6fb13e17bf
commit 5b313d8ad9
4 changed files with 42 additions and 33 deletions
+29 -22
View File
@@ -74,31 +74,38 @@ var GetUserNumber = func() int {
return i
}
func initWebBot() {
if adapter == nil {
adapter = &core.Factory{}
adapter.Init("web", "default")
adapter.SetIsAdmin(func(s string) bool {
isAdmin, ok := webAdmins.Load(s)
if ok {
return isAdmin.(bool)
}
return false
})
adapter.SetReplyHandler(func(msg map[string]string) string {
message := WebMessage{
UserID: msg[core.USER_ID],
Images: []string{},
Type: "chat",
Content: msg[core.CONETNT],
}
sendWebMessage(&message)
return ""
})
}
}
func init() {
core.RegistFuncs["Broadcast2WebUser"] = Broadcast2WebUser
adapter = &core.Factory{}
adapter.Init("web", "default")
adapter.SetIsAdmin(func(s string) bool {
isAdmin, ok := webAdmins.Load(s)
if ok {
return isAdmin.(bool)
}
return false
})
adapter.SetReplyHandler(func(msg map[string]string) string {
message := WebMessage{
UserID: msg[core.USER_ID],
Images: []string{},
Type: "chat",
Content: msg[core.CONETNT],
}
sendWebMessage(&message)
return ""
})
go func() {
time.Sleep(time.Second)
initWebBot()
}()
core.GinApi(core.GET, "/api/web_chat", func(ctx *gin.Context) {
// if adapter == nil {
// }
initWebBot()
rid := ctx.Query("rid")
ctt := ctx.Query("ctt")
token, _ := ctx.Cookie("token")