fixed module path; added translate endpoint to chat API
This commit is contained in:
@@ -51,3 +51,7 @@ csgowtfd:
|
||||
write: 30
|
||||
# seconds before closing idle connections
|
||||
idle: 120
|
||||
deepl:
|
||||
base_url: api-free.deepl.com
|
||||
# get your API key on deepl.com
|
||||
api_key: <api_key>
|
@@ -2,9 +2,9 @@ package csgo
|
||||
|
||||
import (
|
||||
"context"
|
||||
"csgowtfd/ent"
|
||||
"csgowtfd/utils"
|
||||
"fmt"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent"
|
||||
"git.harting.dev/csgowtf/csgowtfd/utils"
|
||||
"github.com/an0nfunc/go-steam/v3"
|
||||
"github.com/an0nfunc/go-steam/v3/csgo/protocol/protobuf"
|
||||
"github.com/an0nfunc/go-steam/v3/netutil"
|
||||
@@ -356,16 +356,11 @@ func (dml *DemoMatchLoader) gcWorker(apiKey string, rl ratelimit.Limiter) {
|
||||
}
|
||||
|
||||
iMatch, err := dml.db.Match.Get(context.Background(), matchId)
|
||||
if err != nil {
|
||||
switch e := err.(type) {
|
||||
case *ent.NotFoundError:
|
||||
break
|
||||
default:
|
||||
log.Errorf("[DL] Failure trying to lookup match %d in db: %v", matchId, e)
|
||||
if err != nil && !ent.IsNotFound(err) {
|
||||
log.Errorf("[DL] Failure trying to lookup match %d in db: %v", matchId, err)
|
||||
dml.unlockDemo(demo)
|
||||
continue
|
||||
}
|
||||
} else {
|
||||
} else if err == nil {
|
||||
if iMatch.DemoParsed == false && iMatch.Date.After(time.Now().UTC().AddDate(0, 0, -30)) {
|
||||
log.Infof("[DL] Match %d is loaded, but not parsed. Try parsing.", iMatch.ID)
|
||||
demo.MatchId = matchId
|
||||
|
@@ -4,12 +4,12 @@ import (
|
||||
"bytes"
|
||||
"compress/bzip2"
|
||||
"context"
|
||||
"csgowtfd/ent"
|
||||
"csgowtfd/ent/match"
|
||||
"csgowtfd/ent/matchplayer"
|
||||
"csgowtfd/ent/player"
|
||||
"encoding/gob"
|
||||
"fmt"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/match"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/matchplayer"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/player"
|
||||
"github.com/golang/geo/r2"
|
||||
"github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs"
|
||||
"github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs/common"
|
||||
@@ -157,7 +157,7 @@ func (dp *DemoParser) MatchPlayerBySteamID(stats []*ent.MatchPlayer, steamId uin
|
||||
for _, tStats := range stats {
|
||||
tPLayer, err := tStats.Edges.PlayersOrErr()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Unbale to get Stats from statList: %v", err)
|
||||
return nil, fmt.Errorf("unable to get stats from statList: %w", err)
|
||||
}
|
||||
if tPLayer.ID == steamId {
|
||||
return tStats, nil
|
||||
|
@@ -7,15 +7,15 @@ import (
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
"csgowtfd/ent/migrate"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/migrate"
|
||||
|
||||
"csgowtfd/ent/match"
|
||||
"csgowtfd/ent/matchplayer"
|
||||
"csgowtfd/ent/messages"
|
||||
"csgowtfd/ent/player"
|
||||
"csgowtfd/ent/roundstats"
|
||||
"csgowtfd/ent/spray"
|
||||
"csgowtfd/ent/weapon"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/match"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/matchplayer"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/messages"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/player"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/roundstats"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/spray"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/weapon"
|
||||
|
||||
"entgo.io/ent/dialect"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
|
14
ent/ent.go
14
ent/ent.go
@@ -3,18 +3,18 @@
|
||||
package ent
|
||||
|
||||
import (
|
||||
"csgowtfd/ent/match"
|
||||
"csgowtfd/ent/matchplayer"
|
||||
"csgowtfd/ent/messages"
|
||||
"csgowtfd/ent/player"
|
||||
"csgowtfd/ent/roundstats"
|
||||
"csgowtfd/ent/spray"
|
||||
"csgowtfd/ent/weapon"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/match"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/matchplayer"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/messages"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/player"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/roundstats"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/spray"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/weapon"
|
||||
)
|
||||
|
||||
// ent aliases to avoid import conflicts in user's code.
|
||||
|
@@ -4,9 +4,10 @@ package enttest
|
||||
|
||||
import (
|
||||
"context"
|
||||
"csgowtfd/ent"
|
||||
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent"
|
||||
// required by schema hooks.
|
||||
_ "csgowtfd/ent/runtime"
|
||||
_ "git.harting.dev/csgowtf/csgowtfd/ent/runtime"
|
||||
|
||||
"entgo.io/ent/dialect/sql/schema"
|
||||
)
|
||||
|
@@ -4,8 +4,9 @@ package hook
|
||||
|
||||
import (
|
||||
"context"
|
||||
"csgowtfd/ent"
|
||||
"fmt"
|
||||
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent"
|
||||
)
|
||||
|
||||
// The MatchFunc type is an adapter to allow the use of ordinary
|
||||
|
@@ -3,12 +3,12 @@
|
||||
package ent
|
||||
|
||||
import (
|
||||
"csgowtfd/ent/match"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/match"
|
||||
)
|
||||
|
||||
// Match is the model entity for the Match schema.
|
||||
|
@@ -3,11 +3,11 @@
|
||||
package match
|
||||
|
||||
import (
|
||||
"csgowtfd/ent/predicate"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/predicate"
|
||||
)
|
||||
|
||||
// ID filters vertices based on their ID field.
|
||||
|
@@ -4,15 +4,15 @@ package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"csgowtfd/ent/match"
|
||||
"csgowtfd/ent/matchplayer"
|
||||
"csgowtfd/ent/player"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/match"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/matchplayer"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/player"
|
||||
)
|
||||
|
||||
// MatchCreate is the builder for creating a Match entity.
|
||||
|
@@ -4,13 +4,13 @@ package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"csgowtfd/ent/match"
|
||||
"csgowtfd/ent/predicate"
|
||||
"fmt"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/match"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/predicate"
|
||||
)
|
||||
|
||||
// MatchDelete is the builder for deleting a Match entity.
|
||||
|
@@ -4,10 +4,6 @@ package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"csgowtfd/ent/match"
|
||||
"csgowtfd/ent/matchplayer"
|
||||
"csgowtfd/ent/player"
|
||||
"csgowtfd/ent/predicate"
|
||||
"database/sql/driver"
|
||||
"errors"
|
||||
"fmt"
|
||||
@@ -16,6 +12,10 @@ import (
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/match"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/matchplayer"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/player"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/predicate"
|
||||
)
|
||||
|
||||
// MatchQuery is the builder for querying Match entities.
|
||||
|
@@ -4,10 +4,6 @@ package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"csgowtfd/ent/match"
|
||||
"csgowtfd/ent/matchplayer"
|
||||
"csgowtfd/ent/player"
|
||||
"csgowtfd/ent/predicate"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
@@ -15,6 +11,10 @@ import (
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/match"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/matchplayer"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/player"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/predicate"
|
||||
)
|
||||
|
||||
// MatchUpdate is the builder for updating Match entities.
|
||||
|
@@ -3,13 +3,13 @@
|
||||
package ent
|
||||
|
||||
import (
|
||||
"csgowtfd/ent/match"
|
||||
"csgowtfd/ent/matchplayer"
|
||||
"csgowtfd/ent/player"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/match"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/matchplayer"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/player"
|
||||
)
|
||||
|
||||
// MatchPlayer is the model entity for the MatchPlayer schema.
|
||||
|
@@ -3,10 +3,9 @@
|
||||
package matchplayer
|
||||
|
||||
import (
|
||||
"csgowtfd/ent/predicate"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/predicate"
|
||||
)
|
||||
|
||||
// ID filters vertices based on their ID field.
|
||||
|
@@ -4,18 +4,18 @@ package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"csgowtfd/ent/match"
|
||||
"csgowtfd/ent/matchplayer"
|
||||
"csgowtfd/ent/messages"
|
||||
"csgowtfd/ent/player"
|
||||
"csgowtfd/ent/roundstats"
|
||||
"csgowtfd/ent/spray"
|
||||
"csgowtfd/ent/weapon"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/match"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/matchplayer"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/messages"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/player"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/roundstats"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/spray"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/weapon"
|
||||
)
|
||||
|
||||
// MatchPlayerCreate is the builder for creating a MatchPlayer entity.
|
||||
|
@@ -4,13 +4,13 @@ package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"csgowtfd/ent/matchplayer"
|
||||
"csgowtfd/ent/predicate"
|
||||
"fmt"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/matchplayer"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/predicate"
|
||||
)
|
||||
|
||||
// MatchPlayerDelete is the builder for deleting a MatchPlayer entity.
|
||||
|
@@ -4,14 +4,6 @@ package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"csgowtfd/ent/match"
|
||||
"csgowtfd/ent/matchplayer"
|
||||
"csgowtfd/ent/messages"
|
||||
"csgowtfd/ent/player"
|
||||
"csgowtfd/ent/predicate"
|
||||
"csgowtfd/ent/roundstats"
|
||||
"csgowtfd/ent/spray"
|
||||
"csgowtfd/ent/weapon"
|
||||
"database/sql/driver"
|
||||
"errors"
|
||||
"fmt"
|
||||
@@ -20,6 +12,14 @@ import (
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/match"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/matchplayer"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/messages"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/player"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/predicate"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/roundstats"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/spray"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/weapon"
|
||||
)
|
||||
|
||||
// MatchPlayerQuery is the builder for querying MatchPlayer entities.
|
||||
|
@@ -4,20 +4,20 @@ package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"csgowtfd/ent/match"
|
||||
"csgowtfd/ent/matchplayer"
|
||||
"csgowtfd/ent/messages"
|
||||
"csgowtfd/ent/player"
|
||||
"csgowtfd/ent/predicate"
|
||||
"csgowtfd/ent/roundstats"
|
||||
"csgowtfd/ent/spray"
|
||||
"csgowtfd/ent/weapon"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/match"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/matchplayer"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/messages"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/player"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/predicate"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/roundstats"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/spray"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/weapon"
|
||||
)
|
||||
|
||||
// MatchPlayerUpdate is the builder for updating MatchPlayer entities.
|
||||
|
@@ -3,12 +3,12 @@
|
||||
package ent
|
||||
|
||||
import (
|
||||
"csgowtfd/ent/matchplayer"
|
||||
"csgowtfd/ent/messages"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/matchplayer"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/messages"
|
||||
)
|
||||
|
||||
// Messages is the model entity for the Messages schema.
|
||||
|
@@ -3,10 +3,9 @@
|
||||
package messages
|
||||
|
||||
import (
|
||||
"csgowtfd/ent/predicate"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/predicate"
|
||||
)
|
||||
|
||||
// ID filters vertices based on their ID field.
|
||||
|
@@ -4,13 +4,13 @@ package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"csgowtfd/ent/matchplayer"
|
||||
"csgowtfd/ent/messages"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/matchplayer"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/messages"
|
||||
)
|
||||
|
||||
// MessagesCreate is the builder for creating a Messages entity.
|
||||
|
@@ -4,13 +4,13 @@ package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"csgowtfd/ent/messages"
|
||||
"csgowtfd/ent/predicate"
|
||||
"fmt"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/messages"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/predicate"
|
||||
)
|
||||
|
||||
// MessagesDelete is the builder for deleting a Messages entity.
|
||||
|
@@ -4,9 +4,6 @@ package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"csgowtfd/ent/matchplayer"
|
||||
"csgowtfd/ent/messages"
|
||||
"csgowtfd/ent/predicate"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math"
|
||||
@@ -14,6 +11,9 @@ import (
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/matchplayer"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/messages"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/predicate"
|
||||
)
|
||||
|
||||
// MessagesQuery is the builder for querying Messages entities.
|
||||
|
@@ -4,15 +4,15 @@ package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"csgowtfd/ent/matchplayer"
|
||||
"csgowtfd/ent/messages"
|
||||
"csgowtfd/ent/predicate"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/matchplayer"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/messages"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/predicate"
|
||||
)
|
||||
|
||||
// MessagesUpdate is the builder for updating Messages entities.
|
||||
|
@@ -4,19 +4,20 @@ package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"csgowtfd/ent/match"
|
||||
"csgowtfd/ent/matchplayer"
|
||||
"csgowtfd/ent/messages"
|
||||
"csgowtfd/ent/player"
|
||||
"csgowtfd/ent/predicate"
|
||||
"csgowtfd/ent/roundstats"
|
||||
"csgowtfd/ent/spray"
|
||||
"csgowtfd/ent/weapon"
|
||||
"errors"
|
||||
"fmt"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/match"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/matchplayer"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/messages"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/player"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/predicate"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/roundstats"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/spray"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/weapon"
|
||||
|
||||
"entgo.io/ent"
|
||||
)
|
||||
|
||||
|
@@ -3,12 +3,12 @@
|
||||
package ent
|
||||
|
||||
import (
|
||||
"csgowtfd/ent/player"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/player"
|
||||
)
|
||||
|
||||
// Player is the model entity for the Player schema.
|
||||
|
@@ -3,11 +3,11 @@
|
||||
package player
|
||||
|
||||
import (
|
||||
"csgowtfd/ent/predicate"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/predicate"
|
||||
)
|
||||
|
||||
// ID filters vertices based on their ID field.
|
||||
|
@@ -4,15 +4,15 @@ package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"csgowtfd/ent/match"
|
||||
"csgowtfd/ent/matchplayer"
|
||||
"csgowtfd/ent/player"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/match"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/matchplayer"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/player"
|
||||
)
|
||||
|
||||
// PlayerCreate is the builder for creating a Player entity.
|
||||
|
@@ -4,13 +4,13 @@ package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"csgowtfd/ent/player"
|
||||
"csgowtfd/ent/predicate"
|
||||
"fmt"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/player"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/predicate"
|
||||
)
|
||||
|
||||
// PlayerDelete is the builder for deleting a Player entity.
|
||||
|
@@ -4,10 +4,6 @@ package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"csgowtfd/ent/match"
|
||||
"csgowtfd/ent/matchplayer"
|
||||
"csgowtfd/ent/player"
|
||||
"csgowtfd/ent/predicate"
|
||||
"database/sql/driver"
|
||||
"errors"
|
||||
"fmt"
|
||||
@@ -16,6 +12,10 @@ import (
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/match"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/matchplayer"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/player"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/predicate"
|
||||
)
|
||||
|
||||
// PlayerQuery is the builder for querying Player entities.
|
||||
|
@@ -4,10 +4,6 @@ package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"csgowtfd/ent/match"
|
||||
"csgowtfd/ent/matchplayer"
|
||||
"csgowtfd/ent/player"
|
||||
"csgowtfd/ent/predicate"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
@@ -15,6 +11,10 @@ import (
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/match"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/matchplayer"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/player"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/predicate"
|
||||
)
|
||||
|
||||
// PlayerUpdate is the builder for updating Player entities.
|
||||
|
@@ -3,12 +3,12 @@
|
||||
package ent
|
||||
|
||||
import (
|
||||
"csgowtfd/ent/matchplayer"
|
||||
"csgowtfd/ent/roundstats"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/matchplayer"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/roundstats"
|
||||
)
|
||||
|
||||
// RoundStats is the model entity for the RoundStats schema.
|
||||
|
@@ -3,10 +3,9 @@
|
||||
package roundstats
|
||||
|
||||
import (
|
||||
"csgowtfd/ent/predicate"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/predicate"
|
||||
)
|
||||
|
||||
// ID filters vertices based on their ID field.
|
||||
|
@@ -4,13 +4,13 @@ package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"csgowtfd/ent/matchplayer"
|
||||
"csgowtfd/ent/roundstats"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/matchplayer"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/roundstats"
|
||||
)
|
||||
|
||||
// RoundStatsCreate is the builder for creating a RoundStats entity.
|
||||
|
@@ -4,13 +4,13 @@ package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"csgowtfd/ent/predicate"
|
||||
"csgowtfd/ent/roundstats"
|
||||
"fmt"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/predicate"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/roundstats"
|
||||
)
|
||||
|
||||
// RoundStatsDelete is the builder for deleting a RoundStats entity.
|
||||
|
@@ -4,9 +4,6 @@ package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"csgowtfd/ent/matchplayer"
|
||||
"csgowtfd/ent/predicate"
|
||||
"csgowtfd/ent/roundstats"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math"
|
||||
@@ -14,6 +11,9 @@ import (
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/matchplayer"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/predicate"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/roundstats"
|
||||
)
|
||||
|
||||
// RoundStatsQuery is the builder for querying RoundStats entities.
|
||||
|
@@ -4,15 +4,15 @@ package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"csgowtfd/ent/matchplayer"
|
||||
"csgowtfd/ent/predicate"
|
||||
"csgowtfd/ent/roundstats"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/matchplayer"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/predicate"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/roundstats"
|
||||
)
|
||||
|
||||
// RoundStatsUpdate is the builder for updating RoundStats entities.
|
||||
|
@@ -3,10 +3,11 @@
|
||||
package ent
|
||||
|
||||
import (
|
||||
"csgowtfd/ent/match"
|
||||
"csgowtfd/ent/player"
|
||||
"csgowtfd/ent/schema"
|
||||
"time"
|
||||
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/match"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/player"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/schema"
|
||||
)
|
||||
|
||||
// The init function reads all schema descriptors with runtime code
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
package runtime
|
||||
|
||||
// The schema-stitching logic is generated in csgowtfd/ent/runtime.go
|
||||
// The schema-stitching logic is generated in git.harting.dev/csgowtf/csgowtfd/ent/runtime.go
|
||||
|
||||
const (
|
||||
Version = "v0.10.0" // Version of ent codegen.
|
||||
|
@@ -3,12 +3,12 @@
|
||||
package ent
|
||||
|
||||
import (
|
||||
"csgowtfd/ent/matchplayer"
|
||||
"csgowtfd/ent/spray"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/matchplayer"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/spray"
|
||||
)
|
||||
|
||||
// Spray is the model entity for the Spray schema.
|
||||
|
@@ -3,10 +3,9 @@
|
||||
package spray
|
||||
|
||||
import (
|
||||
"csgowtfd/ent/predicate"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/predicate"
|
||||
)
|
||||
|
||||
// ID filters vertices based on their ID field.
|
||||
|
@@ -4,13 +4,13 @@ package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"csgowtfd/ent/matchplayer"
|
||||
"csgowtfd/ent/spray"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/matchplayer"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/spray"
|
||||
)
|
||||
|
||||
// SprayCreate is the builder for creating a Spray entity.
|
||||
|
@@ -4,13 +4,13 @@ package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"csgowtfd/ent/predicate"
|
||||
"csgowtfd/ent/spray"
|
||||
"fmt"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/predicate"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/spray"
|
||||
)
|
||||
|
||||
// SprayDelete is the builder for deleting a Spray entity.
|
||||
|
@@ -4,9 +4,6 @@ package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"csgowtfd/ent/matchplayer"
|
||||
"csgowtfd/ent/predicate"
|
||||
"csgowtfd/ent/spray"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math"
|
||||
@@ -14,6 +11,9 @@ import (
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/matchplayer"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/predicate"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/spray"
|
||||
)
|
||||
|
||||
// SprayQuery is the builder for querying Spray entities.
|
||||
|
@@ -4,15 +4,15 @@ package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"csgowtfd/ent/matchplayer"
|
||||
"csgowtfd/ent/predicate"
|
||||
"csgowtfd/ent/spray"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/matchplayer"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/predicate"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/spray"
|
||||
)
|
||||
|
||||
// SprayUpdate is the builder for updating Spray entities.
|
||||
|
@@ -3,12 +3,12 @@
|
||||
package ent
|
||||
|
||||
import (
|
||||
"csgowtfd/ent/matchplayer"
|
||||
"csgowtfd/ent/weapon"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/matchplayer"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/weapon"
|
||||
)
|
||||
|
||||
// Weapon is the model entity for the Weapon schema.
|
||||
|
@@ -3,10 +3,9 @@
|
||||
package weapon
|
||||
|
||||
import (
|
||||
"csgowtfd/ent/predicate"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/predicate"
|
||||
)
|
||||
|
||||
// ID filters vertices based on their ID field.
|
||||
|
@@ -4,13 +4,13 @@ package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"csgowtfd/ent/matchplayer"
|
||||
"csgowtfd/ent/weapon"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/matchplayer"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/weapon"
|
||||
)
|
||||
|
||||
// WeaponCreate is the builder for creating a Weapon entity.
|
||||
|
@@ -4,13 +4,13 @@ package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"csgowtfd/ent/predicate"
|
||||
"csgowtfd/ent/weapon"
|
||||
"fmt"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/predicate"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/weapon"
|
||||
)
|
||||
|
||||
// WeaponDelete is the builder for deleting a Weapon entity.
|
||||
|
@@ -4,9 +4,6 @@ package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"csgowtfd/ent/matchplayer"
|
||||
"csgowtfd/ent/predicate"
|
||||
"csgowtfd/ent/weapon"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math"
|
||||
@@ -14,6 +11,9 @@ import (
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/matchplayer"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/predicate"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/weapon"
|
||||
)
|
||||
|
||||
// WeaponQuery is the builder for querying Weapon entities.
|
||||
|
@@ -4,15 +4,15 @@ package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"csgowtfd/ent/matchplayer"
|
||||
"csgowtfd/ent/predicate"
|
||||
"csgowtfd/ent/weapon"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/matchplayer"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/predicate"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/weapon"
|
||||
)
|
||||
|
||||
// WeaponUpdate is the builder for updating Weapon entities.
|
||||
|
5
go.sum
5
go.sum
@@ -488,6 +488,7 @@ github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOA
|
||||
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
||||
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
|
||||
github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
|
||||
github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
|
||||
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
|
||||
github.com/mattn/go-sqlite3 v1.14.10/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||
@@ -526,6 +527,7 @@ github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+
|
||||
github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs=
|
||||
github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA=
|
||||
github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo=
|
||||
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
|
||||
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
|
||||
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
@@ -619,10 +621,12 @@ github.com/spf13/afero v1.3.3/go.mod h1:5KUK8ByomD5Ti5Artl0RtHeI5pTF7MIDuXL3yY52
|
||||
github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I=
|
||||
github.com/spf13/cast v1.4.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
|
||||
github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
|
||||
github.com/spf13/cobra v1.3.0 h1:R7cSvGu+Vv+qX0gW5R/85dx2kmmJT5z5NM8ifdYjdn0=
|
||||
github.com/spf13/cobra v1.3.0/go.mod h1:BrRVncBjOJa/eUcVVm9CE+oC6as8k+VYr4NY7WCi9V4=
|
||||
github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo=
|
||||
github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
||||
github.com/spf13/pflag v1.0.2/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
||||
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
|
||||
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||
github.com/spf13/viper v1.10.0/go.mod h1:SoyBPwAtKDzypXNDFKN5kzH7ppppbGZtls1UpIy5AsM=
|
||||
github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw=
|
||||
@@ -1022,6 +1026,7 @@ golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||
golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||
golang.org/x/tools v0.1.8-0.20211029000441-d6a9af8af023/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU=
|
||||
golang.org/x/tools v0.1.9-0.20211216111533-8d383106f7e7 h1:M1gcVrIb2lSn2FIL19DG0+/b8nNVKJ7W7b4WcAGZAYM=
|
||||
golang.org/x/tools v0.1.9-0.20211216111533-8d383106f7e7/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU=
|
||||
golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
|
71
main.go
71
main.go
@@ -3,19 +3,20 @@ package main
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"csgowtfd/csgo"
|
||||
"csgowtfd/ent"
|
||||
"csgowtfd/ent/match"
|
||||
"csgowtfd/ent/matchplayer"
|
||||
"csgowtfd/ent/messages"
|
||||
"csgowtfd/ent/migrate"
|
||||
"csgowtfd/ent/player"
|
||||
"csgowtfd/utils"
|
||||
"encoding/gob"
|
||||
"encoding/json"
|
||||
"entgo.io/ent/dialect"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"flag"
|
||||
"fmt"
|
||||
"git.harting.dev/csgowtf/csgowtfd/csgo"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/match"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/matchplayer"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/messages"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/migrate"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/player"
|
||||
"git.harting.dev/csgowtf/csgowtfd/utils"
|
||||
"github.com/go-redis/cache/v8"
|
||||
"github.com/go-redis/redis/v8"
|
||||
"github.com/gorilla/handlers"
|
||||
@@ -25,9 +26,12 @@ import (
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/wercker/journalhook"
|
||||
"go.uber.org/ratelimit"
|
||||
"golang.org/x/text/language"
|
||||
"gopkg.in/yaml.v3"
|
||||
"io"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"os/signal"
|
||||
"strconv"
|
||||
@@ -653,12 +657,29 @@ func getMatchChat(w http.ResponseWriter, r *http.Request) {
|
||||
defer r.Body.Close()
|
||||
|
||||
id := mux.Vars(r)["id"]
|
||||
trans := r.FormValue("translate")
|
||||
|
||||
if id == "" {
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
tag, _, err := language.ParseAcceptLanguage(r.Header.Get("Accept-Language"))
|
||||
if err != nil {
|
||||
log.Warningf("[GMC] Unable to parse Accept-Language %s: %v", r.Header.Get("Accept-Language"), err)
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
var translate bool
|
||||
if trans != "" {
|
||||
translate, err = strconv.ParseBool(trans)
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
matchId, err := strconv.ParseUint(id, 10, 64)
|
||||
if err != nil {
|
||||
log.Infof("[GMC] Error parsing matchID %s: %v", id, err)
|
||||
@@ -681,6 +702,39 @@ func getMatchChat(w http.ResponseWriter, r *http.Request) {
|
||||
resp[steamid] = make([]*utils.ChatResponse, 0)
|
||||
}
|
||||
|
||||
if translate {
|
||||
lang, _ := tag[0].Base()
|
||||
v := url.Values{}
|
||||
v.Set("auth_key", conf.Csgowtfd.DeepL.APIKey)
|
||||
v.Set("text", stat.Message)
|
||||
v.Set("target_lang", lang.String())
|
||||
dlResp, err := http.PostForm("https://"+conf.Csgowtfd.DeepL.BaseURL+"/v2/translate", v)
|
||||
if err != nil || dlResp.StatusCode != http.StatusOK {
|
||||
log.Warningf("[GMC] Unable to translate with DeepL: %v (HTTP %d)", err, dlResp.StatusCode)
|
||||
goto sendNormalResp
|
||||
} else {
|
||||
respBytes, err := io.ReadAll(dlResp.Body)
|
||||
if err != nil {
|
||||
log.Warningf("[GMC] Unable to translate with DeepL: %v (HTTP %d)", err, dlResp.StatusCode)
|
||||
goto sendNormalResp
|
||||
}
|
||||
dlRespJSON := new(utils.DeepLResponse)
|
||||
err = json.Unmarshal(respBytes, &dlRespJSON)
|
||||
if err != nil {
|
||||
log.Warningf("[GMC] Unable to unmarshal JSON from DeepL: %v", err)
|
||||
goto sendNormalResp
|
||||
}
|
||||
resp[steamid] = append(resp[steamid], &utils.ChatResponse{
|
||||
Message: dlRespJSON.Translations[0].Text,
|
||||
AllChat: stat.AllChat,
|
||||
Tick: stat.Tick,
|
||||
TranslatedFrom: dlRespJSON.Translations[0].DetectedSourceLanguage,
|
||||
TranslatedTo: lang.String(),
|
||||
})
|
||||
}
|
||||
continue
|
||||
}
|
||||
sendNormalResp:
|
||||
resp[steamid] = append(resp[steamid], &utils.ChatResponse{
|
||||
Message: stat.Message,
|
||||
AllChat: stat.AllChat,
|
||||
@@ -1126,6 +1180,7 @@ func main() {
|
||||
|
||||
router.HandleFunc(`/match/{id:\d{19}}/chat`, func(writer http.ResponseWriter, request *http.Request) {}).Methods(http.MethodOptions)
|
||||
router.HandleFunc(`/match/{id:\d{19}}/chat`, getMatchChat).Methods(http.MethodGet)
|
||||
router.HandleFunc(`/match/{id:\d{19}}/chat`, getMatchChat).Queries("translate", "{translate}").Methods(http.MethodGet)
|
||||
|
||||
router.HandleFunc(`/matches`, func(writer http.ResponseWriter, request *http.Request) {}).Methods(http.MethodOptions)
|
||||
router.HandleFunc(`/matches`, getMatches).Methods(http.MethodGet)
|
||||
|
@@ -2,17 +2,17 @@ package utils
|
||||
|
||||
import (
|
||||
"context"
|
||||
"csgowtfd/ent"
|
||||
"csgowtfd/ent/match"
|
||||
"csgowtfd/ent/matchplayer"
|
||||
"csgowtfd/ent/player"
|
||||
"csgowtfd/ent/roundstats"
|
||||
"csgowtfd/ent/spray"
|
||||
"csgowtfd/ent/weapon"
|
||||
"encoding/json"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"errors"
|
||||
"fmt"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/match"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/matchplayer"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/player"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/roundstats"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/spray"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/weapon"
|
||||
"github.com/an0nfunc/go-steamapi"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"go.uber.org/ratelimit"
|
||||
@@ -69,6 +69,10 @@ type Conf struct {
|
||||
Write int
|
||||
Idle int
|
||||
}
|
||||
DeepL struct {
|
||||
BaseURL string `yaml:"base_url"`
|
||||
APIKey string `yaml:"api_key"`
|
||||
} `yaml:"deepl"`
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,6 +91,13 @@ type ShareCodeResponse struct {
|
||||
} `json:"result"`
|
||||
}
|
||||
|
||||
type DeepLResponse struct {
|
||||
Translations []struct {
|
||||
DetectedSourceLanguage string `json:"detected_source_language"`
|
||||
Text string `json:"text"`
|
||||
} `json:"translations"`
|
||||
}
|
||||
|
||||
type MatchStats struct {
|
||||
Win int `json:"win,omitempty"`
|
||||
Tie int `json:"tie,omitempty"`
|
||||
@@ -165,6 +176,9 @@ type ChatResponse struct {
|
||||
Message string `json:"message"`
|
||||
AllChat bool `json:"all_chat"`
|
||||
Tick int `json:"tick"`
|
||||
Translated bool `json:"translated,omitempty"`
|
||||
TranslatedFrom string `json:"translated_from,omitempty"`
|
||||
TranslatedTo string `json:"translated_to,omitempty"`
|
||||
}
|
||||
|
||||
type WeaponDmg struct {
|
||||
|
Reference in New Issue
Block a user