KOOKIIEStudios / PalCON-Discord

A Python-based Discord bot for PalWorld server administration via RCON
MIT License
18 stars 3 forks source link

[BUG] If an in-game setting that is not English is entered, the bot cannot output it. #6

Open ssw1279 opened 9 months ago

ssw1279 commented 9 months ago

If there's a language other than English We found a problem that server info or connection name is not output and time out. I don't know if it's a server problem or a bot coding problem. It seems to be a text encoding problem. Can you check it? For your information, I use KOREAN.

Bratah123 commented 9 months ago

I can check this out, can you provide images of the error and how to reproduce it?

ssw1279 commented 9 months ago

Screenshot 2024-02-01 at 15 06 41 When I search for a user, I get the following message. And Discord usually has an error message.

KOOKIIEStudios commented 9 months ago

The RCON library we're using seems to be making assumptions about the encoding - this is something we can't do much about, unfortunately (unless we're looking into implementing our own Palworld RCON library from scratch)

Bratah123 commented 9 months ago

The RCON library we're using seems to be making assumptions about the encoding - this is something we can't do much about, unfortunately (unless we're looking into implementing our own Palworld RCON library from scratch)

Possibly consider making this an issue post on the RCON repo?

KOOKIIEStudios commented 9 months ago

Possibly consider making this an issue post on the RCON repo?

Technically we're appropriating a Minecraft-specific RCON client library so I'm not too keen on that. This is especially because the Palworld's RCON server implementation doesn't follow RCON specifications properly.

Ideal solution is to wireshark and clean room RE (unless Pocketpair has published their spec somewhere)

SeungWoonSong commented 9 months ago

Oh my. i just got a same issue. As it mentioned it could be my RCON Client issue. i will figure it out

PiKWULF commented 9 months ago

I have a player that have special caracther in his name, and when he joins the server bot stops working, and gives same error edit: I edited his name, and fixed it

Bratah123 commented 9 months ago

This seems to be a limitation of the RCON library we are using, we have talks of creating our own RCON library for pal world usage, that may allow us to add multiple language support. Stay tuned

subyoung commented 9 months ago

I got the same issue. Is it possible let it show the PlayerUID or steamID when the name is not english, or we can point a newname to show up in discord when it comes to this specific steamID? Just use ifelse to give a new name to show.

KOOKIIEStudios commented 9 months ago

Let me clarify.

The RCON library we're relying on assumes that the game server's response will contain only Latin characters, and freaks out when there's non-latin characters. As such it simply doesn't give a useable output when there's non-Englisb names.

The fix for this is for us to write our own Palworld-specific RCON library instead of appropriating a Minecraft RCON library.

Also ICYWW, we've tested other generic RCON libraries and found them unsatisfactory for Palworld.

KOOKIIEStudios commented 9 months ago

Circumvention

I made an experimental build using a different RCON library. If anyone on this thread would like to help test it out here's how:

Option 1: Fresh Clone

  1. Clone the utf branch
  2. Follow through steps 3-5 for the remainder of environment installation steps in the README

Option 2: Re-use Existing Clone

  1. Pull changes and switch branch
    • git fetch
    • git pull
    • git switch utf
  2. Delete venv folder
    • rm -r venv
  3. Re-run setup.sh or start.bat to re-configure the virtual environment with the new dependencies

Technical Details for Nerds

As mentioned in the README, I initially used Richard Neumann's RCON client implementation, but switched to tama's implementation due to Palworld's RCON server not following the Source RCON spec (which resulted in constant timeouts).

The former supports Unicode, whilst the latter assumes ASCII - this is the source of problems for non-Latin player names; the former recently received a PR that allowed ignoring of response IDs (which defaulted to 0 instead of the correct corresponding ID for everything except initial login) which resolved our issue with said library and is used in the aforementioned branch. This new utf branch grabs the latest non-stable build from GitHub, since this fix is not yet available on PyPi.

Cursory Testing Details for Nerds

I've done cursory testing on my testbench and verified that it works with Korean IGNs. It did, however, timeout when I was spamming announcements. I would appreciate if users who require non-Latin text compatibility test this new branch out, and see if it resolves your issues (and conversely if this introduces any new problems). image

ssw1279 commented 9 months ago

2024-02-08 13:18:05,487 - client - DEBUG - Lines: [] [2024-02-08 13:18:05] [ERROR ] discord.app_commands.tree: Ignoring exception in command 'online' Traceback (most recent call last): File "C:\Users\MY COM\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\app_commands\commands.py", line 828, in _do_call return await self._callback(interaction, **params) # type: ignore ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\PalCON-Discord\main.py", line 106, in online await interaction.response.send_message(embed=embed_message) File "C:\Users\MY COM\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\interactions.py", line 801, in send_message await adapter.create_interactionresponse( File "C:\Users\MY COM\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\webhook\async.py", line 219, in request raise NotFound(response, data) discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "C:\Users\MY COM\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\app_commands\tree.py", line 1248, in _call await command._invoke_with_namespace(interaction, namespace) File "C:\Users\MY COM\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\app_commands\commands.py", line 853, in _invoke_with_namespace return await self._do_call(interaction, transformed_values) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\MY COM\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\app_commands\commands.py", line 846, in _do_call raise CommandInvokeError(self, e) from e discord.app_commands.errors.CommandInvokeError: Command 'online' raised an exception: NotFound: 404 Not Found (error code: 10062): Unknown interaction

I'm getting an error. I've reinstalled it a few times. I'll try again on another computer for now. Maybe the Python is twisted.

subyoung commented 9 months ago

192.168.86.18212024-02-07 23:22:12,296 - client - DEBUG - Fetching online players Unexpected terminator: b'' 2024-02-07 23:22:42,347 - client - DEBUG - Lines: [] 2024-02-07 23:22:42 ERROR discord.app_commands.tree Ignoring exception in command 'online' Traceback (most recent call last): File "/Volumes/WD850x-ZX/PalCON-Discord/venv/lib/python3.11/site-packages/discord/app_commands/commands.py", line 828, in _do_call return await self._callback(interaction, **params) # type: ignore ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Volumes/WD850x-ZX/PalCON-Discord/main.py", line 106, in online await interaction.response.send_message(embed=embed_message) File "/Volumes/WD850x-ZX/PalCON-Discord/venv/lib/python3.11/site-packages/discord/interactions.py", line 801, in send_message await adapter.create_interactionresponse( File "/Volumes/WD850x-ZX/PalCON-Discord/venv/lib/python3.11/site-packages/discord/webhook/async.py", line 221, in request raise HTTPException(response, data) discord.errors.HTTPException: 400 Bad Request (error code: 40060): Interaction has already been acknowledged.

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/Volumes/WD850x-ZX/PalCON-Discord/venv/lib/python3.11/site-packages/discord/app_commands/tree.py", line 1248, in _call await command._invoke_with_namespace(interaction, namespace) File "/Volumes/WD850x-ZX/PalCON-Discord/venv/lib/python3.11/site-packages/discord/app_commands/commands.py", line 853, in _invoke_with_namespace return await self._do_call(interaction, transformed_values) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Volumes/WD850x-ZX/PalCON-Discord/venv/lib/python3.11/site-packages/discord/app_commands/commands.py", line 846, in _do_call raise CommandInvokeError(self, e) from e discord.app_commands.errors.CommandInvokeError: Command 'online' raised an exception: HTTPException: 400 Bad Request (error code: 40060): Interaction has already been acknowledged. 2024-02-07 23:23:00,996 - client - DEBUG - Fetching online players Unexpected terminator: b'' 2024-02-07 23:23:31,054 - client - DEBUG - Lines: [] 2024-02-07 23:23:31 ERROR discord.app_commands.tree Ignoring exception in command 'online' Traceback (most recent call last): File "/Volumes/WD850x-ZX/PalCON-Discord/venv/lib/python3.11/site-packages/discord/app_commands/commands.py", line 828, in _do_call return await self._callback(interaction, **params) # type: ignore ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Volumes/WD850x-ZX/PalCON-Discord/main.py", line 106, in online await interaction.response.send_message(embed=embed_message) File "/Volumes/WD850x-ZX/PalCON-Discord/venv/lib/python3.11/site-packages/discord/interactions.py", line 801, in send_message await adapter.create_interactionresponse( File "/Volumes/WD850x-ZX/PalCON-Discord/venv/lib/python3.11/site-packages/discord/webhook/async.py", line 221, in request raise HTTPException(response, data) discord.errors.HTTPException: 400 Bad Request (error code: 40060): Interaction has already been acknowledged.

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/Volumes/WD850x-ZX/PalCON-Discord/venv/lib/python3.11/site-packages/discord/app_commands/tree.py", line 1248, in _call await command._invoke_with_namespace(interaction, namespace) File "/Volumes/WD850x-ZX/PalCON-Discord/venv/lib/python3.11/site-packages/discord/app_commands/commands.py", line 853, in _invoke_with_namespace return await self._do_call(interaction, transformed_values) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Volumes/WD850x-ZX/PalCON-Discord/venv/lib/python3.11/site-packages/discord/app_commands/commands.py", line 846, in _do_call raise CommandInvokeError(self, e) from e discord.app_commands.errors.CommandInvokeError: Command 'online' raised an exception: HTTPException: 400 Bad Request (error code: 40060): Interaction has already been acknowledged. 2024-02-07 23:23:58,482 - client - DEBUG - Fetching online players 2024-02-07 23:24:14,642 - client - DEBUG - Fetching server info 2024-02-07 23:24:23,115 - client - DEBUG - Saving world 2024-02-07 23:24:23 ERROR discord.app_commands.tree Ignoring exception in command 'save' Traceback (most recent call last): File "/Volumes/WD850x-ZX/PalCON-Discord/venv/lib/python3.11/site-packages/discord/app_commands/commands.py", line 828, in _do_call return await self._callback(interaction, **params) # type: ignore ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Volumes/WD850x-ZX/PalCON-Discord/main.py", line 130, in save await interaction.response.send_message(embed=embed_message) File "/Volumes/WD850x-ZX/PalCON-Discord/venv/lib/python3.11/site-packages/discord/interactions.py", line 801, in send_message await adapter.create_interactionresponse( File "/Volumes/WD850x-ZX/PalCON-Discord/venv/lib/python3.11/site-packages/discord/webhook/async.py", line 219, in request raise NotFound(response, data) discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/Volumes/WD850x-ZX/PalCON-Discord/venv/lib/python3.11/site-packages/discord/app_commands/tree.py", line 1248, in _call await command._invoke_with_namespace(interaction, namespace) File "/Volumes/WD850x-ZX/PalCON-Discord/venv/lib/python3.11/site-packages/discord/app_commands/commands.py", line 853, in _invoke_with_namespace return await self._do_call(interaction, transformed_values) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Volumes/WD850x-ZX/PalCON-Discord/venv/lib/python3.11/site-packages/discord/app_commands/commands.py", line 846, in _do_call raise CommandInvokeError(self, e) from e discord.app_commands.errors.CommandInvokeError: Command 'save' raised an exception: NotFound: 404 Not Found (error code: 10062): Unknown interaction Unexpected terminator: b'' 2024-02-07 23:24:28,526 - client - DEBUG - Lines: [] 2024-02-07 23:24:28 ERROR discord.app_commands.tree Ignoring exception in command 'online' Traceback (most recent call last): File "/Volumes/WD850x-ZX/PalCON-Discord/venv/lib/python3.11/site-packages/discord/app_commands/commands.py", line 828, in _do_call return await self._callback(interaction, **params) # type: ignore ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Volumes/WD850x-ZX/PalCON-Discord/main.py", line 106, in online await interaction.response.send_message(embed=embed_message) File "/Volumes/WD850x-ZX/PalCON-Discord/venv/lib/python3.11/site-packages/discord/interactions.py", line 801, in send_message await adapter.create_interactionresponse( File "/Volumes/WD850x-ZX/PalCON-Discord/venv/lib/python3.11/site-packages/discord/webhook/async.py", line 221, in request raise HTTPException(response, data) discord.errors.HTTPException: 400 Bad Request (error code: 40060): Interaction has already been acknowledged.

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/Volumes/WD850x-ZX/PalCON-Discord/venv/lib/python3.11/site-packages/discord/app_commands/tree.py", line 1248, in _call await command._invoke_with_namespace(interaction, namespace) File "/Volumes/WD850x-ZX/PalCON-Discord/venv/lib/python3.11/site-packages/discord/app_commands/commands.py", line 853, in _invoke_with_namespace return await self._do_call(interaction, transformed_values) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Volumes/WD850x-ZX/PalCON-Discord/venv/lib/python3.11/site-packages/discord/app_commands/commands.py", line 846, in _do_call raise CommandInvokeError(self, e) from e discord.app_commands.errors.CommandInvokeError: Command 'online' raised an exception: HTTPException: 400 Bad Request (error code: 40060): Interaction has already been acknowledged.

Me, too. The player name is in Chinese and using the new dependency caused error when calling /online and /save.

ssw1279 commented 9 months ago

discord.errors.NotFound: 404 Not Found (error code: 10062):

https://stackoverflow.com/questions/73361556/error-discord-errors-notfound-404-not-found-error-code-10062-unknown-inter

Discord api seems to have timed out receiving information. I'm using an external rental server, not an internal server. Simple save commands work fine, but I think there's a problem with server-side delays in getting the data.

KOOKIIEStudios commented 8 months ago

For once, I'm at a loss since I can't replicate your issues on neither Win11 nor Ubuntu 22.04

image It works fine on my testbenches

KOOKIIEStudios commented 8 months ago

2024-02-08 13:18:05,487 - client - DEBUG - Lines: [] [2024-02-08 13:18:05] [ERROR ] discord.app_commands.tree: Ignoring exception in command 'online' Traceback (most recent call last): File "C:\Users\MY COM\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\app_commands\commands.py", line 828, in _do_call return await self._callback(interaction, **params) # type: ignore ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\PalCON-Discord\main.py", line 106, in online await interaction.response.send_message(embed=embed_message) File "C:\Users\MY COM\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\interactions.py", line 801, in send_message await adapter.create_interactionresponse( File "C:\Users\MY COM\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\webhook\async.py", line 219, in request raise NotFound(response, data) discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "C:\Users\MY COM\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\app_commands\tree.py", line 1248, in _call await command._invoke_with_namespace(interaction, namespace) File "C:\Users\MY COM\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\app_commands\commands.py", line 853, in _invoke_with_namespace return await self._do_call(interaction, transformed_values) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\MY COM\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\app_commands\commands.py", line 846, in _do_call raise CommandInvokeError(self, e) from e discord.app_commands.errors.CommandInvokeError: Command 'online' raised an exception: NotFound: 404 Not Found (error code: 10062): Unknown interaction

I'm getting an error. I've reinstalled it a few times. I'll try again on another computer for now. Maybe the Python is twisted.

For this one, I'm guessing it's timing out - I'll have to double check the timeout duration for RCON side, to make sure that it's kept within 3 seconds

Although the proper way to handle this is probably to use the .defer() method to allow the slash command to not time out before the internal RCON client gives a response to the Discord bot