update to new go-steam version
This commit is contained in:
71
main.go
71
main.go
@@ -5,11 +5,20 @@ import (
|
||||
"compress/gzip"
|
||||
"context"
|
||||
"encoding/gob"
|
||||
"entgo.io/ent/dialect"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"errors"
|
||||
"flag"
|
||||
"fmt"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/signal"
|
||||
"strconv"
|
||||
"strings"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"github.com/gin-contrib/cors"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/go-redis/cache/v8"
|
||||
@@ -21,10 +30,6 @@ import (
|
||||
"golang.org/x/text/language"
|
||||
"golang.org/x/time/rate"
|
||||
"gopkg.in/yaml.v3"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/signal"
|
||||
"somegit.dev/anonfunc/gositemap"
|
||||
"somegit.dev/csgowtf/csgowtfd/csgo"
|
||||
"somegit.dev/csgowtf/csgowtfd/ent"
|
||||
@@ -34,10 +39,6 @@ import (
|
||||
"somegit.dev/csgowtf/csgowtfd/ent/migrate"
|
||||
"somegit.dev/csgowtf/csgowtfd/ent/player"
|
||||
"somegit.dev/csgowtf/csgowtfd/utils"
|
||||
"strconv"
|
||||
"strings"
|
||||
"syscall"
|
||||
"time"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -111,7 +112,7 @@ func housekeeping() {
|
||||
Where(
|
||||
match.And(
|
||||
match.HasPlayersWith(player.ID(bp.ID)),
|
||||
match.DateLTE(bp.GameBanDate.AddDate(0, 0, 30)), //nolint:gomnd
|
||||
match.DateLTE(bp.GameBanDate.AddDate(0, 0, 30)),
|
||||
)).
|
||||
SetGamebanPresent(true).Exec(context.Background())
|
||||
if err != nil {
|
||||
@@ -123,7 +124,7 @@ func housekeeping() {
|
||||
Where(
|
||||
match.And(
|
||||
match.HasPlayersWith(player.ID(bp.ID)),
|
||||
match.DateLTE(bp.VacDate.AddDate(0, 0, 30)), //nolint:gomnd
|
||||
match.DateLTE(bp.VacDate.AddDate(0, 0, 30)),
|
||||
)).SetVacPresent(true).Exec(context.Background())
|
||||
if err != nil {
|
||||
log.Warningf("[HK] Unable to set gameban/vac for match: %v", err)
|
||||
@@ -700,28 +701,26 @@ func getMatchChat(c *gin.Context) {
|
||||
resp[steamid] = make([]*utils.ChatResponse, 0)
|
||||
}
|
||||
|
||||
if translate {
|
||||
translated, srcLang, err := utils.TranslateWithDeepL(stat.Message, lang.String(),
|
||||
conf.DeepL.BaseURL, conf.DeepL.APIKey, conf.DeepL.Timeout)
|
||||
if err != nil {
|
||||
log.Warningf("[GMC] Unable to translate %s with DeepL: %v", stat.Message, err)
|
||||
goto sendNormalResp
|
||||
}
|
||||
|
||||
if srcLang == lang.String() || strings.TrimSpace(translated) == strings.TrimSpace(stat.Message) {
|
||||
goto sendNormalResp
|
||||
}
|
||||
|
||||
resp[steamid] = append(resp[steamid], &utils.ChatResponse{
|
||||
Message: translated,
|
||||
AllChat: stat.AllChat,
|
||||
Tick: stat.Tick,
|
||||
TranslatedFrom: srcLang,
|
||||
TranslatedTo: lang.String(),
|
||||
})
|
||||
|
||||
continue
|
||||
translated, srcLang, err := utils.TranslateWithDeepL(stat.Message, lang.String(),
|
||||
conf.DeepL.BaseURL, conf.DeepL.APIKey, conf.DeepL.Timeout)
|
||||
if err != nil {
|
||||
log.Warningf("[GMC] Unable to translate %s with DeepL: %v", stat.Message, err)
|
||||
goto sendNormalResp
|
||||
}
|
||||
|
||||
if srcLang == lang.String() || strings.TrimSpace(translated) == strings.TrimSpace(stat.Message) {
|
||||
goto sendNormalResp
|
||||
}
|
||||
|
||||
resp[steamid] = append(resp[steamid], &utils.ChatResponse{
|
||||
Message: translated,
|
||||
AllChat: stat.AllChat,
|
||||
Tick: stat.Tick,
|
||||
TranslatedFrom: srcLang,
|
||||
TranslatedTo: lang.String(),
|
||||
})
|
||||
|
||||
continue
|
||||
sendNormalResp:
|
||||
resp[steamid] = append(resp[steamid], &utils.ChatResponse{
|
||||
Message: stat.Message,
|
||||
@@ -818,7 +817,7 @@ func getMatchWeapons(c *gin.Context) {
|
||||
}
|
||||
|
||||
victim := strconv.FormatUint(wr.Victim, 10)
|
||||
mWr[playerID][victim] = append(mWr[playerID][victim], []int{wr.EqType, wr.HitGroup, int(wr.Dmg)})
|
||||
mWr[playerID][victim] = append(mWr[playerID][victim], []int{wr.EqType, wr.HitGroup, int(wr.Dmg)}) //nolint:gosec
|
||||
|
||||
if _, exist := mResponse.EquipmentMap[wr.EqType]; !exist {
|
||||
mResponse.EquipmentMap[wr.EqType] = common.EquipmentType(wr.EqType).String()
|
||||
@@ -1080,7 +1079,7 @@ func getSiteMapIndex(c *gin.Context) {
|
||||
|
||||
func getSiteMap(c *gin.Context) {
|
||||
if c.Param("id") == "" {
|
||||
_ = c.AbortWithError(http.StatusBadRequest, fmt.Errorf("no index specified"))
|
||||
_ = c.AbortWithError(http.StatusBadRequest, errors.New("no index specified"))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1097,7 +1096,7 @@ func getSiteMap(c *gin.Context) {
|
||||
}
|
||||
|
||||
if res == nil {
|
||||
_ = c.AbortWithError(http.StatusNotFound, fmt.Errorf("sitemap does not exist"))
|
||||
_ = c.AbortWithError(http.StatusNotFound, errors.New("sitemap does not exist"))
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user