MCPcopy Index your code
hub / github.com/FloatTech/ZeroBot-Plugin / getNumberFor

Method getNumberFor

plugin/mcfish/main.go:496–521  ·  view source on GitHub ↗

获取某关键字的数量

(uid int64, thing string)

Source from the content-addressed store, hash-verified

494
495// 获取某关键字的数量
496func (sql *fishdb) getNumberFor(uid int64, thing string) (number int, err error) {
497 name := strconv.FormatInt(uid, 10) + "Pack"
498 sql.Lock()
499 defer sql.Unlock()
500 userInfo := article{}
501 err = sql.db.Create(name, &userInfo)
502 if err != nil {
503 return
504 }
505 count, err := sql.db.Count(name)
506 if err != nil {
507 return
508 }
509 if count == 0 {
510 return
511 }
512 if !sql.db.CanFind(name, "WHERE Name glob ?", "*"+thing+"*") {
513 return
514 }
515 info := article{}
516 err = sql.db.FindFor(name, &info, "WHERE Name glob ?", func() error {
517 number += info.Number
518 return nil
519 }, "*"+thing+"*")
520 return
521}
522
523// 获取用户的某类物品信息
524func (sql *fishdb) getUserTypeInfo(uid int64, thingType string) (thingInfos []article, err error) {

Callers 4

initFunction · 0.80
initFunction · 0.80
initFunction · 0.80
initFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected