wangkaiyue 2 år sedan
förälder
incheckning
66168a632c
5 ändrade filer med 131 tillägg och 12 borttagningar
  1. 3 6
      internal/controller/chatWs.go
  2. 0 1
      internal/model/question.go
  3. 1 1
      internal/model/ws.go
  4. 123 0
      manifest/fsw/广告.dict
  5. 4 4
      utility/resource.go

+ 3 - 6
internal/controller/chatWs.go

@@ -35,12 +35,9 @@ var ChatWs = func(r *ghttp.Request) {
 			_ = ws.Close()
 			return
 		}
-		rv := model.ChatLimit.GetBucket(wsChat.Ctx, session.AccountId).TakeAvailable(1)
-		g.Log().Info(wsChat.Ctx, "c----", rv)
-		if rv == 0 {
-			g.Log().Info(wsChat.Ctx, "请求频繁")
-			_ = ws.WriteJSON(g.Map{"error_code": 0, "error_msg": g.Cfg().MustGet(wsChat.Ctx, "limit.exceedMsg").String()})
-			return
+		if model.ChatLimit.GetBucket(wsChat.Ctx, session.AccountId).TakeAvailable(1) == 0 {
+			_ = ws.WriteJSON(g.Map{"error_code": -1, "error_msg": g.Cfg().MustGet(wsChat.Ctx, "limit.exceedMsg").String(), "data": nil})
+			continue
 		}
 		// 处理ws
 		wsChat.Handle(ws, msg)

+ 0 - 1
internal/model/question.go

@@ -92,7 +92,6 @@ func (q *cQuestion) getIsbusinessData(ctx context.Context, code string) (bRes *B
 // DetailQuestion 问题处理
 func (q *cQuestion) DetailQuestion(ctx context.Context, qRes *QuestionReq) (reply string, from int, err error) {
 	cRes, err := ChatGpt.Do(ctx, qRes)
-	g.Dump(qRes.Prompt, "---", cRes)
 	if err != nil {
 		return "", 0, err
 	}

+ 1 - 1
internal/model/ws.go

@@ -67,7 +67,7 @@ func (m *WsChat) Handle(ws *ghttp.WebSocket, msg []byte) {
 
 		if err = utility.ResourcePowerDeduct(m.Ctx, jSession.AccountId, jSession.EntAccountId, fmt.Sprintf("%d", id)); err != nil {
 			g.Log().Error(m.Ctx, "扣减异常", err)
-			return "", fmt.Errorf("扣减异常")
+			return "", err
 		}
 		return reply, nil
 	}()

+ 123 - 0
manifest/fsw/广告.dict

@@ -0,0 +1,123 @@
+兼职
+招聘
+网络
+QQ
+招聘
+有意者
+到货
+本店
+代购
+扣扣
+客服
+微店
+兼职
+兼值
+淘宝
+小姐
+妓女
+包夜
+3P
+LY
+JS
+狼友
+技师
+推油
+胸推
+BT
+毒龙
+口爆
+兼职
+楼凤
+足交
+口暴
+口交
+全套
+SM
+桑拿
+吞精
+咪咪
+婊子
+乳方
+操逼
+全职
+性伴侣
+网购
+网络工作
+代理
+专业代理
+帮忙点一下
+帮忙点下
+请点击进入
+详情请进入
+私人侦探
+私家侦探
+针孔摄象
+调查婚外情
+信用卡提现
+无抵押贷款
+广告代理
+原音铃声
+借腹生子
+找个妈妈
+找个爸爸
+代孕妈妈
+代生孩子
+代开发票
+腾讯客服电话
+销售热线
+免费订购热线
+低价出售
+款到发货
+回复可见
+连锁加盟
+加盟连锁
+免费二级域名
+免费使用
+免费索取
+蚁力神
+婴儿汤
+售肾
+刻章办
+买小车
+套牌车
+玛雅网
+电脑传讯
+视频来源
+下载速度
+高清在线
+全集在线
+在线播放
+txt下载
+六位qq
+6位qq
+位的qq
+个qb
+送qb
+用刀横向切腹
+完全自杀手册
+四海帮
+足球投注
+地下钱庄
+中国复兴党
+阿波罗网
+曾道人
+六合彩
+改卷内幕
+替考试
+隐形耳机
+出售答案
+考中答案
+答an
+da案
+资金周转
+救市
+股市圈钱
+崩盘
+资金短缺
+证监会
+质押贷款
+小额贷款
+周小川
+刘明康
+尚福林
+孔丹

+ 4 - 4
utility/resource.go

@@ -47,13 +47,13 @@ func ResourcePowerDeduct(ctx g.Ctx, accountId, entAccountId int64, id string) er
 	//0:失败 1:成功 -1:不在有效期内 -2:数量不足 -3:没有授权
 	switch res.Status {
 	case 0:
-		return fmt.Errorf("账户 accountId:%d entAccountId:%d 扣除业务失败  聊天记录:%s权限", accountId, entAccountId, id)
+		return fmt.Errorf("资源异常")
 	case -1:
-		return fmt.Errorf("账户 accountId:%d entAccountId:%d 扣除业务权限失败,权限已过期 聊天记录:%s权限", accountId, entAccountId, id)
+		return fmt.Errorf("权益已过期")
 	case -2:
-		return fmt.Errorf("账户 accountId:%d entAccountId:%d 扣除业务权限失败,余额不足 聊天记录:%s权限", accountId, entAccountId, id)
+		return fmt.Errorf("对不起,当日提问已达上限,请明日再来吧~")
 	case -3:
-		return fmt.Errorf("账户 accountId:%d entAccountId:%d 扣除业务权限失败,没有授权 聊天记录:%s权限", accountId, entAccountId, id)
+		return fmt.Errorf("资源权限异常")
 	}
 	return nil
 }