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 » 17 Mar 2019 10:41

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: 6577
Joined: 22 Jan 2005 19:31
Location: Wakefield, West Yorkshire

Re: Thoughts about Discord Integration?

Post by Redirect Left » 17 Mar 2019 11:16

That reminds me, Discord used to recognise when i was playing OpenTTD, it no longer does :(
Image
Worst Behaved IRC Member of 2008, 2009 & 2010 - Go Me!

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

Re: Thoughts about Discord Integration?

Post by Froinchi » 17 Mar 2019 13:06

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
Director
Director
Posts: 565
Joined: 08 Jan 2003 23:09
Location: Denmark

Re: Thoughts about Discord Integration?

Post by jfs » 18 Mar 2019 15:37

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 » 18 Mar 2019 15:49

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: 7414
Joined: 17 Jan 2007 00:14

Re: Thoughts about Discord Integration?

Post by Eddi » 19 Mar 2019 15:13

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.
You might not exactly be interested in Ferion, but if you are, have fun :)

User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9288
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Thoughts about Discord Integration?

Post by planetmaker » 19 Mar 2019 15:23

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 » 19 Mar 2019 15:25

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
Director
Director
Posts: 565
Joined: 08 Jan 2003 23:09
Location: Denmark

Re: Thoughts about Discord Integration?

Post by jfs » 19 Mar 2019 15:37

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: 9288
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Thoughts about Discord Integration?

Post by planetmaker » 19 Mar 2019 16:50

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
Director
Director
Posts: 565
Joined: 08 Jan 2003 23:09
Location: Denmark

Re: Thoughts about Discord Integration?

Post by jfs » 19 Mar 2019 17:14

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: 155
Joined: 14 Apr 2017 15:51
Location: Czech Republic

Re: Thoughts about Discord Integration?

Post by agentw4b » 19 Mar 2019 17:53

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:Experimental games 01 (92.63.57.152:3979), Experimental games 02 (92.63.57.152:3879), Experimental games 03 (92.63.57.152:3779), Experimental games 04 (92.63.57.152:3679), Experimental games 05 (92.63.57.152:3579).
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: 6577
Joined: 22 Jan 2005 19:31
Location: Wakefield, West Yorkshire

Re: Thoughts about Discord Integration?

Post by Redirect Left » 19 Mar 2019 19:05

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
Worst Behaved IRC Member of 2008, 2009 & 2010 - Go Me!

User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9288
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Thoughts about Discord Integration?

Post by planetmaker » 20 Mar 2019 11:26

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: 52
Joined: 18 Jul 2018 17:26
Location: Germany

Re: Thoughts about Discord Integration?

Post by PNDA_ » 03 Jul 2019 21:04

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 55 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
Image

Post Reply

Return to “OpenTTD Suggestions”

Who is online

Users browsing this forum: No registered users and 2 guests