x
This commit is contained in:
+29
-22
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user