Skip to content

Commit

Permalink
feat(gh-124): automated database backups (#125)
Browse files Browse the repository at this point in the history
refactor: heavily refactors the database schema and bot commands

chore: update nitrite version from 3.x to 4.x

feat(gh-123): prepare for leaderboards

docs: update documentation

fix: better error handling

fix: improve error messages for ServerQueryClient

fix: native hints for bot companion

chore: add debug log at the start of the update loop

fix: build native image with march=compatibility to support older cpus
  • Loading branch information
DarkAtra authored Aug 11, 2024
1 parent 2be15f2 commit b2a3e03
Show file tree
Hide file tree
Showing 98 changed files with 3,957 additions and 1,949 deletions.
42 changes: 9 additions & 33 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,14 @@ concurrency:
group: ci-main

permissions:
# used by semantic release
contents: write
issues: write
pull-requests: write
# used to publish the docker image
packages: write
# used by trivy
security-events: write
contents: read

jobs:
verify:
name: Verify
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis

- name: Set up JDK 17
uses: actions/setup-java@v4
Expand All @@ -52,22 +43,23 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis

- uses: graalvm/setup-graalvm@v1.0.12
- uses: graalvm/setup-graalvm@v1.2.1
with:
java-version: '17'
# distribution: 'graalvm'
version: '22.3.2'
components: 'native-image'
java-version: '21'
distribution: 'graalvm-community'

- name: Run tests
run: mvn -B -ntp -PnativeTest verify

release:
name: Build and Release
runs-on: ubuntu-latest
permissions:
# required by semantic release
contents: write
# required to publish the docker image
packages: write
needs:
- verify
- verify-native
Expand All @@ -91,19 +83,3 @@ jobs:
@semantic-release/exec
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Get Image Name
id: get-image-name
run: echo "image-name=$(mvn help:evaluate -Dexpression=image.name -q -DforceStdout)" >> $GITHUB_OUTPUT

- name: Scan Docker Image for Vulnerabilities
uses: aquasecurity/[email protected]
with:
image-ref: ${{ steps.get-image-name.outputs.image-name }}
format: sarif
output: trivy-results.sarif

- name: Upload Trivy Results to GitHub Security Tab
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: trivy-results.sarif
8 changes: 3 additions & 5 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,10 @@ jobs:
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis

- uses: graalvm/setup-graalvm@v1.0.12
- uses: graalvm/setup-graalvm@v1.2.1
with:
java-version: '17'
# distribution: 'graalvm'
version: '22.3.2'
components: 'native-image'
java-version: '21'
distribution: 'graalvm-community'

- name: Run tests
run: mvn -B -ntp -PnativeTest verify
2 changes: 1 addition & 1 deletion .github/workflows/scan-docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
run: echo "image-name=$(mvn help:evaluate -Dexpression=image.name -q -DforceStdout)" >> $GITHUB_OUTPUT

- name: Scan Docker Image for Vulnerabilities
uses: aquasecurity/trivy-action@0.12.0
uses: aquasecurity/trivy-action@0.24.0
with:
image-ref: ${{ steps.get-image-name.outputs.image-name }}
format: sarif
Expand Down
Binary file removed .mvn/wrapper/maven-wrapper.jar
Binary file not shown.
5 changes: 3 additions & 2 deletions .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.4/apache-maven-3.9.4-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar
wrapperVersion=3.3.2
distributionType=only-script
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.7/apache-maven-3.8.7-bin.zip
16 changes: 9 additions & 7 deletions docs/bot-as-a-service.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,28 @@ Please [reach out](https://discord.gg/KcMcYKa6Nt) if something doesn't work for
## Setup Guide

1. [Invite Jarvis (the bot) to your discord server](https://discord.com/oauth2/authorize?client_id=982682186207592470).
2. Create a new channel that is dedicated for the status embed.
2. Create a new channel that is designated for the status embed.
3. Restrict the permissions for the new channel so that members of your server can read messages but can not post anything in there.
This includes the following permissions:
* `View Channel`
* `Read Message History`
4. Ensure that `Jarvis` is allowed to read and write to the channel. This includes the following permissions:
4. Ensure that `Jarvis` is allowed to read from and write to the channel. This includes the following permissions:
* `View Channel`
* `Send Messages`
* `Embed Links`
* `Manage Messages`
* `Read Message History`
5. Ensure that `ListOnSteam` in `ServerHostSettings.json` is set to `true`. This is required for the status embed to work.
6. Find the `IP Address` and `Query Port` of your V Rising server. [Battlemetrics](https://www.battlemetrics.com/servers/vrising) might come in handy here.
7. Navigate to the channel that you created in step 2 and use the `/add-server` command. Discord will ask you for a `server-hostname` and `server-query-port`.
6. Find the `IP Address` and `Query Port` of your v rising server. [Battlemetrics](https://www.battlemetrics.com/servers/vrising) might come in handy here.
7. Use the `/add-server` command and specify the `server-hostname` and `server-query-port`.
This is where you enter the `IP Address` and `Query Port` that you determined in the previous step.
8. `Jarvis` will respond with a message telling you that you've successfully added your first status monitor for your V Rising server.
9. Now you only need to wait a minute for the status display to appear.
You will receive a `server-id` when to command completed successfully. You will need this id in the next step.
8. Use the `/configure-status-monitor` command and specify the `server-id` and `channel-id`.
The `channel-id` determines in which channel the status embed is posted.
9. Wait for a few minutes for the status embed to appear.

{: .note }
> If no status embed appears after 2 minutes, use the `/get-server-details` command with the id that `Jarvis` gave you in step 7.
> If no status embed appears after 3 minutes, use the `/get-server-details` command with the `server-id` that `Jarvis` gave you in step 7.
> This will give you a detailed error message of what went wrong. In most cases, it simply means that the `IP Address` or `Query Port` are incorrect.
> You can always change them using the `/update-server` command. Feel free to check [the commands documentation](commands.md) for details.
Expand Down
21 changes: 12 additions & 9 deletions docs/bot-companion.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@ It does this by exposing [additional http endpoints](#endpoints) on the servers
> I highly recommend not exposing the api port to the internet in an unprotected manner. The setup guide below explains how the API port can be secured using
> Basic Authentication.
{: .warning }
> It is **not** possible to use the bot-companion with GPortal hosted server as they don't allow exposing the API port to the internet.
## Setup Guide

1. [Install BepInEx](https://github.com/decaprime/VRising-Modding/releases) on your V Rising server.
1. [Install BepInEx](https://github.com/decaprime/VRising-Modding/releases) on your v rising server.
2. Download the [v-rising-discord-bot-companion.dll](https://github.com/DarkAtra/v-rising-discord-bot-companion/releases)
* **or** clone [this repo](https://github.com/DarkAtra/v-rising-discord-bot-companion) and build it via `dotnet build`. This
requires [dotnet 6.0](https://dotnet.microsoft.com/en-us/download/dotnet/6.0).
Expand All @@ -27,9 +30,8 @@ It does this by exposing [additional http endpoints](#endpoints) on the servers
"BindPort": 25570
}
```
**It is not recommended to expose the api port to the internet in an unprotected manner.** Consider protecting the api port using a reverse proxy that
supports basic authentication or by using a firewall rule.
5. Start the V Rising server and test if the mod works as expect by running the following command in your
**It is not recommended to expose the api port to the internet in an unprotected manner.** More on that in the next few steps.
5. Start the v rising server and test if the mod works as expect by running the following command in your
terminal: `curl -v http://localhost:25570/v-rising-discord-bot/characters`. Expect status code `200 OK` as soon as the server has fully started.
6. Secure the API port using [Basic Authentication](https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication). Navigate to the `BepInEx/config` folder
and open `v-rising-discord-bot-companion.cfg`. The file should look something like this:
Expand Down Expand Up @@ -67,16 +69,17 @@ It does this by exposing [additional http endpoints](#endpoints) on the servers

1. Make sure you're using [the latest version](https://github.com/DarkAtra/v-rising-discord-bot/releases) of the discord bot.
* **Tip**: You can also find the current docker image [here](https://github.com/DarkAtra/v-rising-discord-bot/pkgs/container/v-rising-discord-bot)
2. Use the `/update-server` command to update the status monitor and set both `server-api-hostname`, `server-api-port`, `server-api-username`
and `server-api-password`. If the V Rising server and the discord bot are hosted on the same machine, set `server-api-hostname` to `localhost`
2. Use the `/update-server` command to update the server and specify a `server-api-hostname`, `server-api-port`, `server-api-username`
and `server-api-password`. If the v rising server and the discord bot are hosted on the same machine, set `server-api-hostname` to `localhost`
and `server-api-port` to `25570` if you used the `ServerHostSettings.json` from above.
3. You should see the gear level for each player in the status embed the next time it is updated.

### Enabling the activity or kill feed

1. Use the `/update-server` command to update the status monitor and set `player-activity-feed-channel-id` to the id of the discord channel you want the
activity feed to appear in. You can do the same for the kill feed by setting `pvp-kill-feed-channel-id`.
2. The bot will now post a message whenever a player joins or leaves the server or whenever someone was killed in a PvP battle. It looks something like this:
1. Use the `/configure-player-activity-feed` or `/configure-pvp-kill-feed` command and set `channel-id`
to the id of the discord channel you want the player activity feed or pvp kill feed to appear in.
2. The bot will now post a message whenever a player joins or leaves the server or whenever someone was killed in a PvP battle.
It looks something like this:

<img alt="Companion Preview" src="assets/companion-preview.png" width="400"/>

Expand Down
Loading

0 comments on commit b2a3e03

Please sign in to comment.