-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from leighmacdonald/cleanups
Big cleanup and refactor pass for first public release
- Loading branch information
Showing
26 changed files
with
1,154 additions
and
3,922 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
name: build | ||
|
||
on: | ||
push: | ||
pull_request: | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
IMAGE_NAME: ${{ github.repository }} | ||
|
||
permissions: write-all | ||
|
||
jobs: | ||
lint-golangci: | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version: '1.22' | ||
|
||
- name: golangci-lint | ||
uses: golangci/golangci-lint-action@v3 | ||
with: | ||
version: 'latest' | ||
args: --timeout=10m | ||
|
||
staticcheck: | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version: '1.22' | ||
- run: go install honnef.co/go/tools/cmd/staticcheck@latest | ||
- run: make static | ||
|
||
tests: | ||
needs: [lint-golangci, staticcheck] | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version: '1.22' | ||
- name: Run tests | ||
run: make test | ||
|
||
release: | ||
name: "tf2bdd release" | ||
runs-on: "ubuntu-latest" | ||
needs: [tests] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- run: git fetch --force --tags | ||
|
||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version: '1.22' | ||
|
||
- run: go mod tidy | ||
|
||
- uses: goreleaser/goreleaser-action@v5 | ||
if: success() && startsWith(github.ref, 'refs/tags/v') | ||
with: | ||
distribution: goreleaser | ||
version: latest | ||
args: release --clean | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Upload snapshot | ||
if: success() && ${{ startsWith(github.ref, 'refs/tags/v') }} | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: snapshot | ||
path: build/* | ||
retention-days: 1 | ||
|
||
- name: Log in to registry | ||
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin | ||
|
||
- name: Build & publish image | ||
if: success() && startsWith(github.ref, 'refs/tags/v') | ||
run: | | ||
docker build . --tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${GITHUB_REF##*/} | ||
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${GITHUB_REF##*/} | ||
docker build . --tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest | ||
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
.idea | ||
/tf2bdd | ||
*.sqlite | ||
*.sqlite | ||
/tf2bdd.exe | ||
|
||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
linters: | ||
# Disable all linters. | ||
# Default: false | ||
disable-all: true | ||
# Enable specific linter | ||
# https://golangci-lint.run/usage/linters/#enabled-by-default | ||
enable: | ||
- asasalint | ||
- asciicheck | ||
- bidichk | ||
- bodyclose | ||
- containedctx | ||
#- contextcheck | ||
- cyclop | ||
- decorder | ||
#- depguard | ||
- dogsled | ||
#- dupl | ||
- dupword | ||
- durationcheck | ||
- errcheck | ||
- errchkjson | ||
- errname | ||
- errorlint | ||
- execinquery | ||
- exhaustive | ||
#- exhaustruct | ||
- exportloopref | ||
- forbidigo | ||
- forcetypeassert | ||
- funlen | ||
- gci | ||
- ginkgolinter | ||
- gocheckcompilerdirectives | ||
#- gochecknoglobals | ||
- gochecknoinits | ||
#- gocognit | ||
#- goconst | ||
- gocritic | ||
- gocyclo | ||
- godot | ||
- godox | ||
#- goerr113 | ||
- gofmt | ||
- gofumpt | ||
- goheader | ||
- goimports | ||
#- gomnd | ||
- gomoddirectives | ||
- gomodguard | ||
- goprintffuncname | ||
- gosec | ||
- gosimple | ||
- govet | ||
- grouper | ||
- importas | ||
- ineffassign | ||
- interfacebloat | ||
#- ireturn | ||
#- lll | ||
- loggercheck | ||
- maintidx | ||
- makezero | ||
- misspell | ||
- musttag | ||
- nakedret | ||
- nestif | ||
- nilerr | ||
- nilnil | ||
- nlreturn | ||
- noctx | ||
- nolintlint | ||
- nonamedreturns | ||
- nosprintfhostport | ||
#- paralleltest | ||
- prealloc | ||
- predeclared | ||
- promlinter | ||
- reassign | ||
- revive | ||
- rowserrcheck | ||
- sqlclosecheck | ||
#- staticcheck | ||
- stylecheck | ||
#- tagliatelle | ||
- tenv | ||
- testableexamples | ||
- testpackage | ||
- thelper | ||
- tparallel | ||
- typecheck | ||
- unconvert | ||
- unparam | ||
- unused | ||
- usestdlibvars | ||
- varnamelen | ||
- wastedassign | ||
- whitespace | ||
#- wrapcheck | ||
#- wsl | ||
#- zerologlint | ||
|
||
linters-settings: | ||
tagliatelle: | ||
case: | ||
use-field-name: true | ||
rules: | ||
json: snake | ||
yaml: snake | ||
funlen: | ||
# Checks the number of lines in a function. | ||
# If lower than 0, disable the check. | ||
# Default: 60 | ||
lines: 130 | ||
# Checks the number of statements in a function. | ||
# If lower than 0, disable the check. | ||
# Default: 40 | ||
statements: -1 | ||
cyclop: | ||
max-complexity: 25 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json | ||
# vim: set ts=2 sw=2 tw=0 fo=cnqoj | ||
|
||
version: 1 | ||
|
||
before: | ||
hooks: | ||
- go mod tidy | ||
|
||
builds: | ||
- env: | ||
- CGO_ENABLED=0 | ||
goos: | ||
- linux | ||
- windows | ||
|
||
release: | ||
github: | ||
owner: leighmacdonald | ||
name: tf2bdd | ||
draft: false | ||
replace_existing_draft: true | ||
prerelease: auto | ||
archives: | ||
- format: tar.gz | ||
# this name template makes the OS and Arch compatible with the results of `uname`. | ||
name_template: >- | ||
{{ .ProjectName }}_ | ||
{{- title .Os }}_ | ||
{{- if eq .Arch "amd64" }}x86_64 | ||
{{- else if eq .Arch "386" }}i386 | ||
{{- else }}{{ .Arch }}{{ end }} | ||
{{- if .Arm }}v{{ .Arm }}{{ end }} | ||
# use zip for windows archives | ||
format_overrides: | ||
- goos: windows | ||
format: zip | ||
|
||
changelog: | ||
sort: asc | ||
filters: | ||
exclude: | ||
- "^docs:" | ||
- "^test:" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,58 @@ | ||
# TF2BDd | ||
|
||
Simple service to send new player lists to the bot detector. | ||
Very simple service to allow tools like those listed below to download and integrate player list contributions from outside sources. This | ||
is designed to work over discord as a bot, allowing multiple people to contribute their lists and have them merged into | ||
a single master list. The results served over an HTTP endpoint `/v1/steamids`. Data is backed by a very simple sqlite database. | ||
|
||
## Usage | ||
- [tf2_bot_detector](https://github.com/PazerOP/tf2_bot_detector) | ||
- [bd](https://github.com/leighmacdonald/bd) | ||
- [MAC](https://github.com/MegaAntiCheat) | ||
|
||
If you have other examples of software that is able to update lists over http like these, please open a PR to add them to the list. | ||
|
||
Example results from the [@trusted](https://trusted.roto.lol/v1/steamids) list. | ||
|
||
## Commands | ||
|
||
Bot command list: | ||
|
||
- `!add <steamid/profile> [attributes]` Add the user to the master ban list. eg: `suspicious/cheater/bot`. If none are defined, it will use cheater by default. | ||
- `!del <steamid/profile>` Remove the player from the master list | ||
- `!check <steamid/profile>` Checks if the user exists in the database | ||
- `!count` Shows the current count of players tracked | ||
- `!import <attached_playerlist_files>` Imports the steam ids from a players custom ban list, multiple can be attached | ||
- `!steamid <steamid/vanity_name/profile_link>` Accepts any steamid format including bare vanity name and profile link. Will print out all forms. | ||
|
||
Discord [slash commands](https://support.discord.com/hc/en-us/articles/1500000368501-Slash-Commands-FAQ) are not | ||
currently supported as this was written before that was an option, however if there is enough | ||
demand, or somebody creates a PR for it, I will add them. | ||
|
||
## Building From Source | ||
|
||
$ git clone git@github.com:leighmacdonald/tf2bdd.git | ||
$ cd tf2bdd | ||
$ go build | ||
$ export STEAM_TOKEN=steam_web_api_token | ||
$ export BOT_TOKEN=discord_bot_token | ||
|
||
## Running Binary | ||
|
||
You can either use the binary you build from source, or download the latest release from the [releases](https://github.com/leighmacdonald/tf2bdd/releases) | ||
page. | ||
|
||
$ export STEAM_TOKEN=steam_web_api_token # Your steam api key, for resolving vanity names | ||
$ export BOT_TOKEN=discord_bot_token # Your discord bot token | ||
$ export BOT_CLIENTID=12345 # Discord client id | ||
$ export BOT_ROLES=11111111111,222222222 # Roles allowed to use non-readonly commands | ||
$ ./tf2bdd | ||
|
||
## Commands | ||
|
||
Bot command list: | ||
You will probably want to create something like a systemd service to automate this. | ||
|
||
## Running Docker | ||
|
||
`!add <steamid/profile> [attributes]` Add the user to the master ban list. Valid attributes are 0 or more of: `racist sus/suspicious cheater exploiter`. If none are defined, it will use cheater by default. | ||
`!del <steamid/profile>` Remove the player from the master list | ||
`!check <steamid/profile>` Checks if the user exists in the database | ||
`!count` Shows the current count of players tracked | ||
`!import <attach_a_json_file>` Imports the steam ids from a players custom ban list | ||
`!steamid <steamid/profile>` Get the various steam ids | ||
|
||
docker run --rm --name tf2bdd -it \ | ||
-p 127.0.0.1:8899:8899 \ | ||
--env BOT_TOKEN=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx \ | ||
--env STEAM_TOKEN=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx \ | ||
--env BOT_CLIENTID=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx \ | ||
--env BOT_ROLES=111111111111,22222222222 \ | ||
--mount type=bind,source="$(pwd)"/db.sqlite,target=/app/db.sqlite \ | ||
ghcr.io/leighmacdonald/tf2bdd:latest |
Oops, something went wrong.