Thoughts about Discord Integration?

Got an idea for OpenTTD? Post it here!

Moderator: OpenTTD Developers

Post Reply
User avatar
Froinchi
Engineer
Engineer
Posts: 4
Joined: 17 Mar 2019 10:35
Location: Istanbul

Thoughts about Discord Integration?

Post by Froinchi »

Hello everyone!
Since you are re-building the game, I think you can take Discord integration. I am sure that they'll support you!
These are the links that may help you:
https://discordapp.com
https://discordapp.com/rich-presence
https://discordapp.com/verification
User avatar
Redirect Left
Tycoon
Tycoon
Posts: 7238
Joined: 22 Jan 2005 19:31
Location: Wakefield, West Yorkshire

Re: Thoughts about Discord Integration?

Post by Redirect Left »

That reminds me, Discord used to recognise when i was playing OpenTTD, it no longer does :(
Image
Need some good tested AI? - Unofficial AI Tester, list of good stuff & thread is here.
User avatar
Froinchi
Engineer
Engineer
Posts: 4
Joined: 17 Mar 2019 10:35
Location: Istanbul

Re: Thoughts about Discord Integration?

Post by Froinchi »

Redirect Left wrote:That reminds me, Discord used to recognise when i was playing OpenTTD, it no longer does :(
I noticed that too. I must select .exe file manually everytime I open the game.
User avatar
jfs
Tycoon
Tycoon
Posts: 1750
Joined: 08 Jan 2003 23:09
Location: Denmark

Re: Thoughts about Discord Integration?

Post by jfs »

The suggestion has been raised before. The consensus last year was that we don't want integration for specific platforms built in to OpenTTD itself, but may be open to having some general method of querying game status.
User avatar
Froinchi
Engineer
Engineer
Posts: 4
Joined: 17 Mar 2019 10:35
Location: Istanbul

Re: Thoughts about Discord Integration?

Post by Froinchi »

jfs wrote:The suggestion has been raised before. The consensus last year was that we don't want integration for specific platforms built in to OpenTTD itself, but may be open to having some general method of querying game status.
That could be super cool!
Eddi
Tycoon
Tycoon
Posts: 8257
Joined: 17 Jan 2007 00:14

Re: Thoughts about Discord Integration?

Post by Eddi »

we already have an interface in the form of "admin port" (primarily aimed at network servers). it would be nice if we could provide a ready-made script to handle the connection.
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Thoughts about Discord Integration?

Post by planetmaker »

Eddi wrote:we already have an interface in the form of "admin port" (primarily aimed at network servers). it would be nice if we could provide a ready-made script to handle the connection.
Quite right:

There exists a python script which connects to the admin port and communicates ingame to IRC.
https://dev.openttdcoop.org/projects/soap/repository and a fork at https://github.com/ropenttd/suds

This surely can be changed to talk to discord, too, especially as there is a ready-made python API: https://discordpy.readthedocs.io/en/latest/api.html
User avatar
Froinchi
Engineer
Engineer
Posts: 4
Joined: 17 Mar 2019 10:35
Location: Istanbul

Re: Thoughts about Discord Integration?

Post by Froinchi »

planetmaker wrote:
Eddi wrote:we already have an interface in the form of "admin port" (primarily aimed at network servers). it would be nice if we could provide a ready-made script to handle the connection.
Quite right:

There exists a python script which connects to the admin port and communicates ingame to IRC.
https://dev.openttdcoop.org/projects/soap/repository and a fork at https://github.com/ropenttd/suds

This surely can be changed to talk to discord, too, especially as there is a ready-made python API: https://discordpy.readthedocs.io/en/latest/api.html
But there is just little problem. I don't know how to code. I just wanted to come out with an idea.
User avatar
jfs
Tycoon
Tycoon
Posts: 1750
Joined: 08 Jan 2003 23:09
Location: Denmark

Re: Thoughts about Discord Integration?

Post by jfs »

Eddi wrote:we already have an interface in the form of "admin port" (primarily aimed at network servers). it would be nice if we could provide a ready-made script to handle the connection.
Is the admin port usable (or useful) when you are on the main menu? In a singleplayer game? Joined as a client in multiplayer?
The goal here is not to query information about a multiplayer game you are hosting, but to query information about which game you are playing, possibly including server address of a multiplayer session you have joined. Also, from within the IM client (be it Discord or anything else) instruct a running OpenTTD to join a specific server, or to allow friends to request to join your game, still from within their IM client.
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Thoughts about Discord Integration?

Post by planetmaker »

jfs wrote:
Eddi wrote:we already have an interface in the form of "admin port" (primarily aimed at network servers). it would be nice if we could provide a ready-made script to handle the connection.
Is the admin port usable (or useful) when you are on the main menu? In a singleplayer game? Joined as a client in multiplayer?
The goal here is not to query information about a multiplayer game you are hosting, but to query information about which game you are playing, possibly including server address of a multiplayer session you have joined. Also, from within the IM client (be it Discord or anything else) instruct a running OpenTTD to join a specific server, or to allow friends to request to join your game, still from within their IM client.
The admin port only works when OpenTTD runs in server mode (why would you externally control your single-player session?). As such: it is not useful nor even usable at all in main menu as in that case no server is running.

In server mode it can query many game states, including player and map info as well as interactions between them. It is possible to use it as some kind of command-logging; while it does not have every game action available, it can get those via a game script which can have an interface to the admin port as well.
User avatar
jfs
Tycoon
Tycoon
Posts: 1750
Joined: 08 Jan 2003 23:09
Location: Denmark

Re: Thoughts about Discord Integration?

Post by jfs »

Yep exactly. The idea behind an IM client integration is not to query the status of a game server, but to report what the user is doing with the game, whether that's just having it open, playing alone, or playing multiplayer.
agentw4b
Traffic Manager
Traffic Manager
Posts: 216
Joined: 14 Apr 2017 15:51
Location: Czech Republic

Re: Thoughts about Discord Integration?

Post by agentw4b »

there is a path Openttd -> libOTTDAdmin2 -> SUDS bot (Supybot) -> IRC
  -> Discord, I tried to start it, but I couldn't make it completely, too complicated ...
Owner and admin of servers with names "Experimental games" .
My heightmaps: Flat Earth Map and United nations logo
My scenarios: Game Fallout 1,2,3 Map scenario
My gamescripts: City Founder GS
User avatar
Redirect Left
Tycoon
Tycoon
Posts: 7238
Joined: 22 Jan 2005 19:31
Location: Wakefield, West Yorkshire

Re: Thoughts about Discord Integration?

Post by Redirect Left »

I've recently been working with Node to create my Discord bot for my gameserver (not OpenTTD related, San Andreas Multiplayer). So i can give some pointers on how to make the Discord connections, although i woludn't know how to read the OTTD data without looking into it, and then it should be aasy to word into human readable sentences.

The issue I have found, as i was converting from an IRC to a Discord bot. Discord, unlike IRC, doesn't have limitless lines. It is throttles quite heavily, so if your OpenTTD instance outputs lines rapidly, you may get your bot throttled. May not be an issue for OpenTTD, but my IRC bot was spewing out 5+ lines per 10 seconds, which Discord does not like. So be wary of those limit in Discord, compared to IRC.
Image
Need some good tested AI? - Unofficial AI Tester, list of good stuff & thread is here.
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Thoughts about Discord Integration?

Post by planetmaker »

Redirect Left wrote:I've recently been working with Node to create my Discord bot for my gameserver (not OpenTTD related, San Andreas Multiplayer). So i can give some pointers on how to make the Discord connections, although i woludn't know how to read the OTTD data without looking into it, and then it should be aasy to word into human readable sentences.

The issue I have found, as i was converting from an IRC to a Discord bot. Discord, unlike IRC, doesn't have limitless lines. It is throttles quite heavily, so if your OpenTTD instance outputs lines rapidly, you may get your bot throttled. May not be an issue for OpenTTD, but my IRC bot was spewing out 5+ lines per 10 seconds, which Discord does not like. So be wary of those limit in Discord, compared to IRC.
Do you possibly feel like making discord integration into soap / suds? That bot currently connects to IRC. However the detour via IRC is not necessary as in python one can directly connect to discord, too.
Links to repos are at viewtopic.php?f=32&t=84974#p1219543
User avatar
PNDA_
Engineer
Engineer
Posts: 62
Joined: 18 Jul 2018 17:26
Location: Germany

Re: Thoughts about Discord Integration?

Post by PNDA_ »

Hey,
I know it was advised from planetmaker and other devs to use the admin port. I still decided to make it a full integration into the source code of the game. So... Here's what I made to combine OpenTTD and Discord Rich Presence:
openttd+richpresence.zip
(20.73 MiB) Downloaded 282 times
All the basics are finished. Only additional information is not being shown, e.g. current year or map size, whatever. (Would be nice to hear some suggestions what this could be). I'm debating making this a PR into the github repository of OpenTTD... See what the devs think.

Example:
Image

Note: This is based on a fairly new version I pulled from the github.... so this may have a few bugs and it has a few new features coming with 1.10
Hello!
ImageImageImage
Post Reply

Return to “OpenTTD Suggestions”

Who is online

Users browsing this forum: No registered users and 7 guests