4444func init () {
4545 cachePath := engine .DataFolder () + "cache/"
4646 go func () {
47+ sdb = initialize (engine .DataFolder () + "score.db" )
4748 ok := file .IsExist (cachePath )
4849 if ! ok {
4950 err := os .MkdirAll (cachePath , 0777 )
@@ -60,21 +61,20 @@ func init() {
6061 }
6162 }
6263 }
63- sdb = initialize (engine .DataFolder () + "score.db" )
6464 }()
6565 engine .OnMessageFullMatch ("签到" ).Limit (ctxext .LimitByUser ).SetBlock (true ).Handle (func (ctx * nano.Ctx ) {
6666 uid := ctx .Message .Author .ID
6767 if uid == "" {
6868 _ , _ = ctx .SendPlainMessage (false , "ERROR: 未获取到用户uid" )
6969 return
7070 }
71- uidint , _ := strconv .ParseInt (uid , 10 , 64 )
71+ uidint , _ := strconv .ParseUint (uid , 10 , 64 )
7272 today := time .Now ().Format ("20060102" )
7373 // 签到图片
7474 drawedFile := cachePath + uid + today + "signin.png"
7575 picFile := cachePath + uid + today + ".png"
7676 // 获取签到时间
77- si := sdb .GetSignInByUID (uidint )
77+ si := sdb .GetSignInByUID (int64 ( uidint ) )
7878 siUpdateTimeStr := si .UpdatedAt .Format ("20060102" )
7979 switch {
8080 case si .Count >= signinMax && siUpdateTimeStr == today :
@@ -92,28 +92,28 @@ func init() {
9292 return
9393 case siUpdateTimeStr != today :
9494 // 如果是跨天签到就清数据
95- err := sdb .InsertOrUpdateSignInCountByUID (uidint , 0 )
95+ err := sdb .InsertOrUpdateSignInCountByUID (int64 ( uidint ) , 0 )
9696 if err != nil {
9797 _ , _ = ctx .SendPlainMessage (false , "ERROR: " , err )
9898 return
9999 }
100100 }
101101 // 更新签到次数
102- err := sdb .InsertOrUpdateSignInCountByUID (uidint , si .Count + 1 )
102+ err := sdb .InsertOrUpdateSignInCountByUID (int64 ( uidint ) , si .Count + 1 )
103103 if err != nil {
104104 _ , _ = ctx .SendPlainMessage (false , "ERROR: " , err )
105105 return
106106 }
107107 // 更新经验
108- level := sdb .GetScoreByUID (uidint ).Score + 1
108+ level := sdb .GetScoreByUID (int64 ( uidint ) ).Score + 1
109109 if level > SCOREMAX {
110110 level = SCOREMAX
111111 _ , err := ctx .SendPlainMessage (true , "你的等级已经达到上限" )
112112 if err != nil {
113113 _ , _ = ctx .SendPlainMessage (false , "ERROR: " , err )
114114 }
115115 }
116- err = sdb .InsertOrUpdateScoreByUID (uidint , level )
116+ err = sdb .InsertOrUpdateScoreByUID (int64 ( uidint ) , level )
117117 if err != nil {
118118 _ , _ = ctx .SendPlainMessage (false , "ERROR: " , err )
119119 return
@@ -123,7 +123,7 @@ func init() {
123123 add := 1 + rand .Intn (10 ) + rank * 5 // 等级越高获得的钱越高
124124
125125 go func () {
126- err = wallet .InsertWalletOf (uidint , add )
126+ err = wallet .InsertWalletOf (int64 ( uidint ) , add )
127127 if err != nil {
128128 _ , _ = ctx .SendPlainMessage (false , "ERROR: " , err )
129129 return
@@ -135,7 +135,7 @@ func init() {
135135 avatarurl : ctx .Message .Author .Avatar ,
136136 nickname : ctx .Message .Author .Username ,
137137 inc : add ,
138- score : wallet .GetWalletOf (uidint ),
138+ score : wallet .GetWalletOf (int64 ( uidint ) ),
139139 level : level ,
140140 rank : rank ,
141141 }
0 commit comments