Git Product home page Git Product logo

v-rising-discord-bot's Introduction

Hi there 👋

I'm a software developer who mostly works with web technologies, but I also modify old video games from my childhood from time to time. I recently started writing about it in my blog: https://darkatra.dev/

v-rising-discord-bot's People

Contributors

darkatra avatar dependabot[bot] avatar renovate[bot] avatar semantic-release-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

v-rising-discord-bot's Issues

feat: allow restricting server ips to non reserved/private networks

It should be possible to configure the bot to only allow ips from public ip ranges. Ranges in reserved networks should be prohibited, e.g. 10.0.0.0/8, 127.0.0.0/8, 192.168.0.0/16, 172.16.0.0/12 and 169.254.0.0/16 (maybe even more).

Useful:

  • InetAddress#isLoopbackAddress()
  • InetAddress#isLinkLocalAddress()
  • InetAddress#isSiteLocalAddress()

feat(native): create native image

The issue
One of the biggest drawbacks of this bot is its memory consumption. With the recent upgrade to Spring Boot 3 we could try to build a native image using GraalVM.

Proposed solution
Configure the spring-boot-maven-plugin so that it builds a native image via GraalVM. This would result in near instant startup times and lower memory consumption for the bot. It would also eliminate the need for a JVM.

Notes
I've already attempted to build a native image when Spring Boot 3 was released and it didn't work out of the box. The main issue back then was that kotlin coroutines didn't play nicely with native image, see: oracle/graal#5606. Also, the database is using jackson for serialization, e.g. runtime hints are required, see: https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/aot/hint/annotation/RegisterReflectionForBinding.html

fix: NPE when running the docker image

In some cases the bot seems to fail to create the nitrite database.

image

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'database' defined in class path resource [de/darkatra/vrising/discord/DatabaseConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.dizitart.no2.Nitrite]: Factory method 'database' threw exception; nested exception is java.lang.NullPointerException: builder()
            .c?perties.databasePassword) must not be null

Discord Post: https://discord.com/channels/993243434695540837/993243434695540839/1082189504837865492
See also: nitrite/nitrite-java#801

bug: ascii tables exceed discord embed size if there's a lot of players online

Is your feature request related to a problem? Please describe.
If a server has a lot of players online and the ServerStatusMonitor is configured to display the player list using ASCII tables, then the embed field exceeds the maximum size of 1024 characters and the bot is unable to update the embed anymore.

Describe the solution you'd like
The default display mode distributes the player list across multiple embed fields by building batches of 20. This could be an option for the ASCII table mode as well but might look ugly because the table header is printed separately for each batch.

This is a huge blocked for this feature and could mean that i'm not releasing it in the final 2.2.x release.

Context

feat: `/get-server-details` should also log most recent Errors

Describe the solution you'd like
/get-server-details should also print the most recent error messages so that it's possible to get information on why the bot is failing to update a status message without access to the bot's logs. It should not log the whole stacktrace though.

Replace `Days Played` with `Days Running`

Patch 0.5.42553:

  • Replaced “Days Played” with “Days Running” in the Server Details.
  • “Days Played” previously displayed the number of in-game days since server start, “Days Running” will now instead display the number of real-time days since server start.

Bot stops being able to fetch status over time

Running docker 1.6.0 in unRaid 6.9.2
Initial setup works great, then ceases to update overnight.
Removing the game server and adding it again resolves the issue.

java.util.concurrent.CompletionException: java.util.concurrent.RejectedExecutionException
at com.ibasco.agql.protocols.valve.source.query.SourceQueryMessenger$RequestContext.completion(SourceQueryMessenger.java:368) ~[agql-source-query-1.0.5.jar:1.0.5]
at com.ibasco.agql.protocols.valve.source.query.SourceQueryMessenger$RequestContext.access$1000(SourceQueryMessenger.java:279) ~[agql-source-query-1.0.5.jar:1.0.5]
at com.ibasco.agql.protocols.valve.source.query.SourceQueryMessenger.lambda$send$1(SourceQueryMessenger.java:240) ~[agql-source-query-1.0.5.jar:1.0.5]
at java.base/java.util.concurrent.CompletableFuture.uniHandle(Unknown Source) ~[na:na]
at java.base/java.util.concurrent.CompletableFuture.uniHandleStage(Unknown Source) ~[na:na]
at java.base/java.util.concurrent.CompletableFuture.handle(Unknown Source) ~[na:na]
at com.ibasco.agql.protocols.valve.source.query.SourceQueryMessenger.send(SourceQueryMessenger.java:240) ~[agql-source-query-1.0.5.jar:1.0.5]
at com.ibasco.agql.protocols.valve.source.query.SourceQueryMessenger.send(SourceQueryMessenger.java:62) ~[agql-source-query-1.0.5.jar:1.0.5]
at com.ibasco.agql.core.AbstractClient.send(AbstractClient.java:111) ~[agql-lib-core-1.0.5.jar:1.0.5]
at com.ibasco.agql.core.AbstractClient.send(AbstractClient.java:87) ~[agql-lib-core-1.0.5.jar:1.0.5]
at com.ibasco.agql.protocols.valve.source.query.SourceQueryClient.getPlayers(SourceQueryClient.java:228) ~[agql-source-query-1.0.5.jar:1.0.5]
at de.darkatra.vrising.discord.ServerQueryClient.getPlayerList(ServerQueryClient.kt:39) ~[classes/:1.6.0]
at de.darkatra.vrising.discord.ServerStatusMonitorService$launchServerStatusMonitor$1.invokeSuspend(ServerStatusMonitorService.kt:80) ~[classes/:1.6.0]
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) ~[kotlin-stdlib-1.6.21.jar:1.6.21-release-334(1.6.21)]
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106) ~[kotlinx-coroutines-core-jvm-1.6.3.jar:na]
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570) ~[kotlinx-coroutines-core-jvm-1.6.3.jar:na]
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:749) ~[kotlinx-coroutines-core-jvm-1.6.3.jar:na]
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677) ~[kotlinx-coroutines-core-jvm-1.6.3.jar:na]
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664) ~[kotlinx-coroutines-core-jvm-1.6.3.jar:na]
Caused by: java.util.concurrent.RejectedExecutionException: null
at com.ibasco.agql.protocols.valve.source.query.SourceQueryMessenger$RequestContext.execute(SourceQueryMessenger.java:303) ~[agql-source-query-1.0.5.jar:1.0.5]
at com.ibasco.agql.protocols.valve.source.query.SourceQueryMessenger.send(SourceQueryMessenger.java:239) ~[agql-source-query-1.0.5.jar:1.0.5]
... 12 common frames omitted

2022-07-07 07:21:05.038 ERROR 1 --- [atcher-worker-4] d.d.v.d.ServerStatusMonitorService : Exception while fetching the status of bdf8b1eb-fd61-11ec-a5b9-8518966c8d10

feat: allow usage of `/list-servers` im DMs

Is your feature request related to a problem? Please describe.
There is currently no way to list all status monitors for v rising servers across multiple discord servers.

Describe the solution you'd like
It should be possible to use the /list-servers command in DMs to the bot user. This is probably something that only the administrator of the bot should have access to, so the idea is to implement an allowlist for that specific DM command (via discord userId).

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/build.yml
  • actions/checkout v4
  • actions/setup-java v4
  • actions/checkout v4
  • graalvm/setup-graalvm v1.0.12
  • actions/checkout v4
  • actions/setup-java v4
  • cycjimmy/semantic-release-action v3
  • aquasecurity/trivy-action 0.12.0
  • github/codeql-action v3
.github/workflows/pull-request-lint.yml
  • amannn/action-semantic-pull-request v5
.github/workflows/pull-request.yml
  • actions/checkout v4
  • actions/setup-java v4
  • actions/checkout v4
  • graalvm/setup-graalvm v1.0.12
.github/workflows/scan-docker-image.yml
  • actions/checkout v4
  • actions/setup-java v4
  • aquasecurity/trivy-action 0.12.0
  • github/codeql-action v3
maven
pom.xml
  • org.springframework.boot:spring-boot-starter-parent 3.1.3
  • dev.kord:kord-core-jvm 0.10.0
  • com.ibasco.agql:agql-source-query 1.2.1
  • com.fasterxml.uuid:java-uuid-generator 4.3.0
  • org.dizitart:potassium-nitrite 3.4.4
  • commons-validator:commons-validator 1.7
  • org.mockito.kotlin:mockito-kotlin 5.0.0
  • com.github.tomakehurst:wiremock 3.0.0-beta-10
  • org.jetbrains.kotlin:kotlin-maven-plugin 1.8.22
  • org.jetbrains.kotlin:kotlin-maven-allopen 1.8.22
maven-wrapper
.mvn/wrapper/maven-wrapper.properties
  • maven 3.9.4
  • maven-wrapper 3.2.0

  • Check this box to trigger a request for Renovate to run again on this repository

Bot has a memory leak

It seems like the bot has a memory leak in both the jar and native version. It seems to be related to the logic performed in ServerStatusMonitorService#updateServerStatusMonitor as the memory goes up every time a server status monitor is updated. This leak causes the bot to exit after a few hours/days. When running in docker, it restarts automatically if restart: unless-stopped is set in the docker-compose file.

Until this issue is fixed, every user of the bot should limit the amount of memory the bot can allocate to around 512MB and ensure that the bot is restarted if it crashes.

feat: Leaderboard Embed

Describe the solution you'd like
With the introduction of the v-rising-discord-bot-companion it is now possible to fetch additional data from a v rising server. This would allow us to add leaderboards that show, for example, the top 10 players based on their kill/death/assist ratio or by the number of vbloods they killed.

feat: support ascii tables for the player list

Is your feature request related to a problem? Please describe.
Now that the bot also has an option to display the gear level, clan name and amount of killed vbloods, the simple line based visualization in the discord embed reaches its limits.

Describe the solution you'd like
The bot should introduce an option to enable ascii based tables per ServerStatusMonitor. E.g. something like this:

+-----------------+------+
| Column name     | ID   |
+-----------------+------+
| some data0      | 0    |
| some data1      | 1    |
| some data2      | 4    |
| some data3      | 9    |
| some data4      | 16   |
+-----------------+------+

chore: update screenshot in readme

The screenshot of the discord embed in the readme files is quite outdated. It should be updated to reflect what the current version of the bot looking like.

fix: validate that server-hostname is a valid ip or domain name

The bot does not validate that server-hostname is a valid ip or domain name at the moment. This leads to the following exception when the bot attempts to query data from the server: java.nio.channels.UnresolvedAddressException: null

Desired Solution: validation for server-hostname should ensure that an ip address (ipv4 and ipv6) or a domain name is provided and fail otherwise.

See: https://discord.com/channels/993243434695540837/993243434695540839/1082228757802274826

feat: Player Connect/Disconnect History

Feature Request
It should be possible to send notifications in a discord channel whenever a player connects or disconnects from a server.

Preferred Solution
This could be implemented by remembering the previous server player response and creating a diff with the current one. Players that are no longer in the list disconnected. Players that weren't in the previous list but are in the current one joined recently.

It should be possible to enable player activity tracking on a per server basis using the /update-server command. It's probably also a good idea to ask for a different channel to post these logs to. This could be done by passing a discord channel-id to the /update-server command.

Known Limitations
This approach does not track player activity in real time and is limited by the bot.update-delay. By default server information is only fetched every 30 seconds. If a player connects and disconnects within these 30 seconds, no activity would be logged. This is acceptable.

feat: make it possible to control how much information is be visible in the embed

v2.2.0-next.7 added support for displaying the clan and the number of slain vbloods per player. However, at the moment it is not possible to control which information should be displayed in the embed.

Example (which requires the v-rising-discord-bot-companion):
grafik

Feature Request

Make it possible to define which data should be displayed in the embed. E.g. if i only want to display the gear level of a player but not the clan name, that should be possible.

Solution

Introduce properties similar to display-server-description to control if gear-level, clan and slain-vbloods should be visible.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.