Dishorde icon indicating copy to clipboard operation
Dishorde copied to clipboard

Duplicated chat messages in discord when players chat in game

Open breeece opened this issue 11 months ago • 1 comments

Hello, great bot! Loving it so far. Only issue I am receiving is that when players chat in game it is duplicating their messages in the discord. Is it possible it could have something to do with their prefixes? Because we have colors and prefixes setup for when players hit certain milestones or are part of the admin team. So anybody with a prefix or color in their name the chat gets handled by the ServerTools mod. I know you said support for mods that do anything with chat is not supported. Just curious if there is something I could do on my end here. When a player runs a command that begins with a "/" it is not duplicating the message in discord even if that player has a color and prefix.

breeece avatar Mar 05 '24 13:03 breeece

Hello! Sorry to hear you're having issues. Most likely yes, the mods are the cause here and a code modification would be needed to fully fix it.

For the prefixes, the bot detects and automatically filters out messages that it detects starting with a "/". It sounds like what's happening here is the bot filters out the message as it normally would - but then the duplicate still comes through, looking like a normal message.

One thing you can try is playing with the following config options: disable-chatmsgs, disable-join-leave-gmsgs, disable-misc-gmsgs, disable-non-player-gmsgs, and show-private-chat. I can't say for sure what combination will work (if any) as that depends on how the mod is doing things.

If the mod is re-sending chat as a different type of message, maybe something like turning on disable-chatmsgs will do it. Alternatively, setting disable-misc-gmsgs, disable-non-player-chatmsgs to true, and setting disable-chatmsgs to false. Beware these are only wild guesses, but it might be worth a shot.

If you try the above and it works, please let me know so we can help anyone else that has the same problem!

One other thing you can try is making sure you don't have duplicates of the bot running. The bot has auto-detection and if you enable allow-multiple-instances, or something else goes wrong, you can have the same bot sending multiple messages. A telltale sign of this is if even the "help" command shows up twice. If this is the case, the quickest fix is to restart the system the bot is running on - then, start the bot once and try again.

From a technical side, fixing mod conflicts would look something like this:

  1. Enable log-telnet in Dishorde's config, either on your copy or a secondary copy made specifically for testing. a. Alternatively, connect to your 7 Days to Die server with a telnet client. You'd need to research this a bit, as there are a number of ways to do this. Windows 10 has one built-in that can be enabled by typing "Turn Windows features on or off" in the Windows search bar, and then accessed via command prompt.
  2. Examine the logs and see how chat messages are being logged. My guess is that the mod is adding additional logs of a message to the game's console, causing them to show up multiple times. This is only a guess and it could be something completely different. a. Beware that mods have also been found to introduce other trickery, like different line endings or other encoding quirks that can confuse the bot. This can show up in ways like the bot thinking one line of data from the console is actually two, or cramming two lines into one.
  3. Compare these logs to the way the bot interprets them, and optionally the way a default 7 Days to Die outputs them (e.g. repeat steps 1-3 with a vanilla 7 Days to Die server). You can see parts of the code used for interpreting messages at index.js/handleMsgFromGame. A lot of this handling uses Regular Expressions. Sites like Regexr are handy in testing these out.
  4. Program a fix! This depends on whatever is found in the above steps. In the case of color coding, if my suspicion of the duplicated messages is correct, this is probably something an extra filter can be created for. However, it gets complicated fast when you consider multiple mods, different mods doing different things, vanilla doing its own thing, etc etc. Depending on the situation, some mods might have to be either manually detected (e.g. you have to set a config option saying "we have mod X installed") or manually toggled (e.g. the bot looks for a telltale sign of a particular mod being added and, when it does, apply a special regex filter based on this).

Dishorde is a bit of a 'mod-less' solution as-is, being a tool that works with the game without touching the files. At this time, all of this would be a bit too much of a time sink for me. So, for the foreseeable future, I still advise that mods will not be supported.

If you or anyone else opens a pull request with a solution, I'll be happy to look it over. Feel free to reach out if you have any other questions!

LakeYS avatar Mar 08 '24 23:03 LakeYS