mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-19 13:59:39 +08:00
parent
d832f9aaea
commit
8fa928d37f
@ -87,13 +87,13 @@ func dlrange(prefix string, end int, wg *sync.WaitGroup, exit func(error)) []str
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 新的上下文
|
// 新的上下文
|
||||||
func newContext(user int64) *context {
|
func newContext(user int64, atUser int64) *context {
|
||||||
c := new(context)
|
c := new(context)
|
||||||
c.usrdir = datapath + "users/" + strconv.FormatInt(user, 10) + `/`
|
c.usrdir = datapath + "users/" + strconv.FormatInt(atUser, 10) + `/`
|
||||||
_ = os.MkdirAll(c.usrdir, 0755)
|
_ = os.MkdirAll(c.usrdir, 0755)
|
||||||
c.headimgsdir = make([]string, 2)
|
c.headimgsdir = make([]string, 2)
|
||||||
c.headimgsdir[0] = c.usrdir + "0.gif"
|
c.headimgsdir[0] = datapath + "users/" + strconv.FormatInt(atUser, 10) + ".gif"
|
||||||
c.headimgsdir[1] = c.usrdir + "1.gif"
|
c.headimgsdir[1] = datapath + "users/" + strconv.FormatInt(user, 10) + ".gif"
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -14,9 +14,9 @@ func (cc *context) prepareLogos(s ...string) error {
|
|||||||
for i, v := range s {
|
for i, v := range s {
|
||||||
_, err := strconv.Atoi(v)
|
_, err := strconv.Atoi(v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = file.DownloadTo("https://gchat.qpic.cn/gchatpic_new//--"+strings.ToUpper(v)+"/0", cc.usrdir+strconv.Itoa(i)+".gif")
|
err = file.DownloadTo("https://gchat.qpic.cn/gchatpic_new//--"+strings.ToUpper(v)+"/0", cc.headimgsdir[i])
|
||||||
} else {
|
} else {
|
||||||
err = file.DownloadTo("http://q4.qlogo.cn/g?b=qq&nk="+v+"&s=640", cc.usrdir+strconv.Itoa(i)+".gif")
|
err = file.DownloadTo("http://q4.qlogo.cn/g?b=qq&nk="+v+"&s=640", cc.headimgsdir[i])
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@ -152,8 +152,9 @@ func init() { // 插件主体
|
|||||||
datapath = file.BOTPATH + "/" + en.DataFolder()
|
datapath = file.BOTPATH + "/" + en.DataFolder()
|
||||||
en.OnRegex(`^(` + strings.Join(cmd, "|") + `)[\s\S]*?(\[CQ:(image\,file=([0-9a-zA-Z]{32}).*|at.+?(\d{5,11}))\].*|(\d+))$`).
|
en.OnRegex(`^(` + strings.Join(cmd, "|") + `)[\s\S]*?(\[CQ:(image\,file=([0-9a-zA-Z]{32}).*|at.+?(\d{5,11}))\].*|(\d+))$`).
|
||||||
SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||||
c := newContext(ctx.Event.UserID)
|
|
||||||
list := ctx.State["regex_matched"].([]string)
|
list := ctx.State["regex_matched"].([]string)
|
||||||
|
atUserID, _ := strconv.ParseInt(list[4]+list[5]+list[6], 10, 64)
|
||||||
|
c := newContext(ctx.Event.UserID, atUserID)
|
||||||
err := c.prepareLogos(list[4]+list[5]+list[6], strconv.FormatInt(ctx.Event.UserID, 10))
|
err := c.prepareLogos(list[4]+list[5]+list[6], strconv.FormatInt(ctx.Event.UserID, 10))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.SendChain(message.Text("ERROR: ", err))
|
ctx.SendChain(message.Text("ERROR: ", err))
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user