JonnyPtn / zomboi

A discord bot for project zomboid multiplayer servers
49 stars 32 forks source link

Add support for Discord to Game chat #71

Open TheDogg opened 1 year ago

TheDogg commented 1 year ago

Hi, I wasn't sure how to reach you, but I attempted to add support for Discord to Game chat, I have it working when I run my code locally, but for some reason when I use it within a docker container I'm getting a timeout. I am no python expert so maybe you can take a look at my code and maybe you can figure it out.

Have a look at my fork (https://github.com/TheDogg/zomboi), only modified zomboi.py and rcon_adapter.py

Hope fully you can figure it out, having 2 way chat would be really cool.

JonnyPtn commented 1 year ago

Yeah I looked at the server message command when originally implementing this, but I think it causes a sort of global message to pop up for everyone in the game, rather than a regular chat message?

Suspect your docker timeout might be something to do with the rcon connection - do any of the other rcon commands work?

RogueRaiden commented 1 year ago

The base game has support for linking discord chat and game chat. I use it myself along with this bot. Its in the main settings file.

Although it sometimes doesn't work 100%

If RCON could send to the General chat channel instead of the Server channel then it should work. Unsure if RCON can sent to particular channels though

TheDogg commented 1 year ago

Yes it does popup for everyone in game, for our community it is not a problem since it's not an "open to everyone" server.

other rcon commands do work in the docker. If I run the bot as a service directly on the server host it works, I'm still having some timeouts once in a while tho. I must be doing something wrong with the way I call the rcon client, still learning and trying out things.

@RogueRaiden how did you disable the chat in zomboi if you are using the base game discord chat support along with the bot? when I tried it I ended up having duplicate chat messages in discord (1 from zomboi and 1 from the game itself).

the part I dont like about the game discord chat is that you have to reply to the bot in order for the discord message to show up in the game, I prefer just showing any chat from the channel in-game

JonnyPtn commented 1 year ago

If RCON could send to the General chat channel instead of the Server channel then it should work. Unsure if RCON can sent to particular channels though

Yeah this is the reason I never implemented it, because rcon doesn't support it (at least didn't last time I checked)