Your Name 1 year ago
parent
commit
baf1f51fb5
4 changed files with 34 additions and 35 deletions
  1. BIN
      dist/tg/dist/tg
  2. 1 1
      dist/tg/version.txt
  3. 33 33
      tg/game.go
  4. 0 1
      tg/tg.go

BIN
dist/tg/dist/tg


+ 1 - 1
dist/tg/version.txt

@@ -1 +1 @@
-1.0.2211.f1098
+1.0.2211.bb55f

+ 33 - 33
tg/game.go

@@ -56,11 +56,17 @@ func onUpdate(e event2.Event[tgbotapi.Update]) error {
 		return nil
 	}
 
+	if update.InlineQuery != nil || update.ChosenInlineResult != nil {
+		handleInlineQuery(update)
+	}
+
 	if update.CallbackQuery == nil {
 		logrus.Info("CallbackQuery is null")
 		return nil
 	}
 
+	fmt.Println("InlineMessageID", update.CallbackQuery.InlineMessageID)
+
 	tgID := update.CallbackQuery.From.ID
 	gameUserMapModel := model.GameUserMap{}
 	err = db.GetDB().Table("game_user_map").
@@ -97,6 +103,33 @@ func onUpdate(e event2.Event[tgbotapi.Update]) error {
 	return err
 }
 
+func handleInlineQuery(update tgbotapi.Update) error {
+	if update.ChosenInlineResult != nil {
+		fmt.Println("InlineMessageID:", update.ChosenInlineResult.InlineMessageID)
+		return nil
+	}
+
+	btnList := GetGameReplyMarkupSimple()
+
+	queryStr := update.InlineQuery.Query
+
+	gameMsg := &tgbotapi.InlineConfig{
+		InlineQueryID: update.InlineQuery.ID,
+		Results: []interface{}{
+			tgbotapi.InlineQueryResultGame{
+				Type:          "game",
+				ID:            "id_" + queryStr,
+				GameShortName: "qznn",
+				ReplyMarkup:   &btnList,
+			},
+		},
+		CacheTime: 0,
+	}
+
+	go event2.MustFire(EventSendMsgFix, tgbotapi.Chattable(gameMsg))
+	return nil
+}
+
 func handlerMsg(update tgbotapi.Update) error {
 	var err error
 
@@ -507,39 +540,6 @@ func GetYeInfo(tgID int64) (*YERespData, error) {
 	}
 
 	return &respData, nil
-	// 	if update.FromChat().IsPrivate() {
-	// 		textMsg.Text =
-	// 			`ID: ` + userModel.Mobile + `
-	// 用户名: ` + userModel.Nickname + `
-	// 余额: ` + fmt.Sprintf("%.2f", respData.Data.Balance) + `
-	// 今日流水: ` + fmt.Sprintf("%.2f", respData.Data.Amount) + `
-	// 今日输赢: ` + fmt.Sprintf("%.2f", respData.Data.LoseWin) + `
-
-	// 联系<a href='https://t.me/+7nmC1CbItdozZmM1'>上下分客服</a>取款
-	// `
-	// 		SendMsg(textMsg, update, botApi)
-	// 	} else {
-	// 		textMsg.Text =
-	// 			`ID: ` + userModel.Mobile + `
-	// 用户名: ` + userModel.Nickname + `
-	// 余额: ` + fmt.Sprintf("%.2f", respData.Data.Balance) + `
-	// 今日流水: ` + fmt.Sprintf("%.2f", respData.Data.Amount) + `
-	// 今日输赢: ` + fmt.Sprintf("%.2f", respData.Data.LoseWin) + `
-	// `
-
-	// 		shareInfo, err := getShare(tgID)
-	// 		if err != nil {
-	// 			logrus.Error(err)
-	// 			textMsg.Text = "操作失败,内部错误,请稍后重新操作。(531)"
-	// 			botApi.Send(textMsg)
-	// 			return false
-	// 		}
-
-	// 		btnList := GetBtnList(shareInfo)
-
-	// 		textMsg.ReplyMarkup = btnList
-	// 		SendAndDeleteMsg(textMsg, update, botApi, time.Second*60)
-	// 	}
 
 }
 

+ 0 - 1
tg/tg.go

@@ -17,7 +17,6 @@ func Start() {
 
 	event2.On[tgbotapi.Chattable](EventSendMsg, event2.ListenerFunc[tgbotapi.Chattable](MainBot.onSendMsg))
 	event2.On[tgbotapi.Chattable](EventSendMsgFix, event2.ListenerFunc[tgbotapi.Chattable](MainBot.onSendMsgFix))
-	event2.On[tgbotapi.Chattable](EventSendMsgFix, event2.ListenerFunc[tgbotapi.Chattable](MainBot.onSendMsgFix))
 
 	go func() {
 		<-time.After(3 * time.Second)