mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-19 13:59:39 +08:00
fix(emozi): usr login
This commit is contained in:
parent
baf1a80dc2
commit
001fdcceae
@ -23,6 +23,7 @@ func init() {
|
|||||||
})
|
})
|
||||||
usr := emozi.Anonymous()
|
usr := emozi.Anonymous()
|
||||||
data, err := os.ReadFile(en.DataFolder() + "user.txt")
|
data, err := os.ReadFile(en.DataFolder() + "user.txt")
|
||||||
|
hasaccount := false
|
||||||
if err == nil {
|
if err == nil {
|
||||||
arr := strings.Split(string(data), "\n")
|
arr := strings.Split(string(data), "\n")
|
||||||
if len(arr) >= 2 {
|
if len(arr) >= 2 {
|
||||||
@ -33,6 +34,7 @@ func init() {
|
|||||||
usr = emozi.Anonymous()
|
usr = emozi.Anonymous()
|
||||||
} else {
|
} else {
|
||||||
logrus.Infoln("[emozi]", "以", usr, "身份登录成功")
|
logrus.Infoln("[emozi]", "以", usr, "身份登录成功")
|
||||||
|
hasaccount = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -41,8 +43,16 @@ func init() {
|
|||||||
txt := strings.TrimSpace(ctx.State["args"].(string))
|
txt := strings.TrimSpace(ctx.State["args"].(string))
|
||||||
out, chs, err := usr.Marshal(false, txt)
|
out, chs, err := usr.Marshal(false, txt)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.SendChain(message.Text("ERROR: ", err))
|
if hasaccount {
|
||||||
return
|
err = usr.Login()
|
||||||
|
if err == nil {
|
||||||
|
out, chs, err = usr.Marshal(false, txt)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
ctx.SendChain(message.Text("ERROR: ", err))
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if len(chs) == 0 {
|
if len(chs) == 0 {
|
||||||
ctx.Send(message.ReplyWithMessage(ctx.Event.MessageID, message.Text(out)))
|
ctx.Send(message.ReplyWithMessage(ctx.Event.MessageID, message.Text(out)))
|
||||||
@ -71,6 +81,18 @@ func init() {
|
|||||||
en.OnPrefix("抽象还原").Limit(ctxext.LimitByUser).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
en.OnPrefix("抽象还原").Limit(ctxext.LimitByUser).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||||
txt := strings.TrimSpace(ctx.State["args"].(string))
|
txt := strings.TrimSpace(ctx.State["args"].(string))
|
||||||
out, err := usr.Unmarshal(false, txt)
|
out, err := usr.Unmarshal(false, txt)
|
||||||
|
if err != nil {
|
||||||
|
if hasaccount {
|
||||||
|
err = usr.Login()
|
||||||
|
if err == nil {
|
||||||
|
out, err = usr.Unmarshal(false, txt)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
ctx.SendChain(message.Text("ERROR: ", err))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.SendChain(message.Text("ERROR: ", err))
|
ctx.SendChain(message.Text("ERROR: ", err))
|
||||||
return
|
return
|
||||||
@ -91,6 +113,8 @@ func init() {
|
|||||||
ctx.SendChain(message.Text("ERROR: ", err))
|
ctx.SendChain(message.Text("ERROR: ", err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
usr = newusr
|
||||||
|
hasaccount = true
|
||||||
ctx.SendChain(message.Text("成功"))
|
ctx.SendChain(message.Text("成功"))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user