[mod] Empyrion Chat Discord Bridge

Discussion in 'Empyrion API' started by ASTIC, Jun 17, 2024.

  1. ASTIC

    ASTIC Rear Admiral

    Joined:
    Dec 11, 2016
    Messages:
    1,094
    Likes Received:
    735
    Empyrion Chat Discord Bridge

    Latests infos and zip downloads
    https://github.com/GitHub-TC/EmpyrionChatDiscordBridge

    Installation
    Sie können diesen Mod direkt mit dem MOD-Manager von EWA (Empyrion Web Access) laden.
    Ohne den EWA funktioniert der Mod nur innerhalb des EmpyrionModHost

    DiscordBot
    Eine gute Beschreibung zum Erstellen eines DiscordBots findet man hier https://www.writebots.com/discord-bot-token/

    Das Erstellen geschieht über die Developers Seite von Discord https://discordapp.com/developers/applications/

    Der Bot benötigt NUR folgende Rechte

    [​IMG]

    !! WICHTIG !! Damit der Bot auch den Inhalt der Chatmeldungen lesen darf muss noch folgende Einstellung "MESSAGE CONTENT INTENT" erlaubt werden [​IMG]

    Auch sollte der Bot in den Servereinstellungen auf die Kanäle beschränkt werden welche er benötigt. Hier z.B.

    [​IMG] für die Kanäle welche in der Konfiguration der Mod im Savegame hinterlegt sind

    Code:
    {
      "LogLevel": "Message",
      "DiscordLogLevel": "Error",
      "ChatCommandPrefix": "\\/",
      "AutosavePlayerIntervalMS": 30000,
      "DiscordBotToken": "..........Your....Secret... Bot.... Token.........",
      "HideChatsStartsWith": [
       "/",
       "\\",
       "cb:",
       "am:"
      ],
      "AdminChannel": {
       "DiscordChannelName": "egs-admin-chat",
       "ID": 0,
       "FractionAbbrev": "AST"
      },
      "GlobalChannel": {
       "DiscordChannelName": "egs-server",
       "ID": 0,
       "FractionAbbrev": null
      },
      "FractionChannels": [
       {
         "DiscordChannelName": "egs-ast-fraction",
         "ID": 0,
         "FractionAbbrev": "AST"
       }
      ]
    }
    
    Um den globalen Chat einzurichten muss nun einfach über den Discord Kanal (hier "egs-server") ein Chat abgesetzt werden. Die Mod trägt dann automatisch die "ID" des Kanals ein welcher für die Chats, welche aus dem Spiel gesendet werden, benötigt wird.

    Für die Admin und Fraktionschats gilt:

    Man muss InGame ein Chat über den globalen Kanal machen damit die Mod den Spieler kennt [​IMG] und danach über den jeweiligen Discord Kanal einen Chat absetzten damit die Mod die benötigte ID ermitteln kann. [​IMG] [​IMG]

    Nun ist die Discord Bridge vollständig eingerichtet und kann verwendet werden.

    Besondere Kanäle
    • GlobalChannel
      Chats von und zu dem globalen Kanal in Empyrion
    • AdminChannel
      Chat zu einer Adminfraktion in Empyrion. In dem Discord Chat werden alle Globalen- und Fraktionschats ebenfalls eingetragen
      Zu diesen Kanal sollten nur die Admins zugang haben
    • FractionChannels
      Chat von und zu dem fraktions Kanal der jeweiligen Fraktion. Diese ist jeweils mit ihrem Kürzel in "FractionAbbrev" anzugeben
      Zu diesen Kanal sollten nur die Mitglieder der Fraktion zugang haben
    InGame Empyrion
    Über den Chat in Empyrion kann der Status der Kanäle und ob sie eingerichtet sind, ermittelt werden

    • \discord help
      [​IMG]
    Konfiguration
    • LogLevel: Debug,Message,Error
    • DiscordLogLevel: Critical,Error,Warning,Info,Verbose,Debug
    • ChatCommandPrefix Zeichen mit denen das Chatkommando der Mod beginnen muss
    • AutosavePlayerIntervalMS Das Zeitintervall in dem sich die Mod die bekannten Spieler in der Konfiguration speichert um sie offline wieder zu erkennen
    • DiscordBotToken Das Token des Bots
    • HideChatsStartsWith Empyrion Chats welche mit einem dieser Texte beginnen werden nicht nach Discord übertragen
    English-Version:

    Empyrion Chat Discord Bridge
    Installation
    You can load this mod directly with the MOD Manager from EWA (Empyrion Web Access). Without the EWA, the mod only works within the EmpyrionModHost

    DiscordBot
    A good description of how to create a DiscordBot can be found here https://www.writebots.com/discord-bot-token/

    It is created via the developers page of Discord https://discordapp.com/developers/applications/

    The bot ONLY needs the following rights

    [​IMG]

    !! IMPORTANT !! So that the bot can also read the content of the chat messages, the following setting "MESSAGE CONTENT INTENT" must be allowed [​IMG]

    The bot should also be restricted to the channels it needs in the server settings. Here, for example

    [​IMG] for the channels that are stored in the mod configuration in the savegame
    Code:
    {
      "LogLevel": "Message",
      "DiscordLogLevel": "Error",
      "ChatCommandPrefix": "\\/",
      "AutosavePlayerIntervalMS": 30000,
      "DiscordBotToken": "..........Your....Secret... Bot.... Token.........",
      "HideChatsStartsWith": [
       "/",
       "\\",
       "cb:",
       "am:"
      ],
      "AdminChannel": {
       "DiscordChannelName": "egs-admin-chat",
       "ID": 0,
       "FractionAbbrev": "AST"
      },
      "GlobalChannel": {
       "DiscordChannelName": "egs-server",
       "ID": 0,
       "FractionAbbrev": null
      },
      "FractionChannels": [
       {
         "DiscordChannelName": "egs-ast-fraction",
         "ID": 0,
         "FractionAbbrev": "AST"
       }
      ]
    }
    
    To set up the global chat, you simply need to send a chat via the Discord channel (here "egs-server"). The mod then automatically enters the "ID" of the channel, which is required for the chats that are sent from the game.

    The following applies to the admin and faction chats:

    You need to send a chat in-game via the global channel so that the mod knows the player [​IMG] and then send a chat via the respective Discord channel so that the mod can determine the required ID. [​IMG] [​IMG]

    The Discord Bridge is now fully set up and can be used.

    Special channels
    • GlobalChannel
      Chats from and to the global channel in Empyrion
    • AdminChannel
      Chat to an admin faction in Empyrion. All global and faction chats are also entered in the Discord chat. Only the admins should have access to this channel. - FractionChannels Chat from and to the faction channel of the respective faction. This must be specified with its abbreviation in "FractionAbbrev"
      Only members of the faction should have access to this channel
    InGame Empyrion
    The status of the channels and whether they are set up can be determined via the chat in Empyrion

    • \discord help
      [​IMG]
    Configuration
    • LogLevel: Debug,Message,Error
    • DiscordLogLevel: Critical,Error,Warning,Info,Verbose,Debug
    • ChatCommandPrefix Characters with which the mod's chat command must begin
    • AutosavePlayerIntervalMS The time interval in which the mod saves the known players in the configuration in order to recognize them offline
    • DiscordBotToken The bot's token
    • HideChatsStartsWith Empyrion chats that begin with one of these texts are not transferred to Discord
     
    #1
    Last edited: Jun 17, 2024
  2. Puck

    Puck Ensign

    Joined:
    Nov 17, 2024
    Messages:
    5
    Likes Received:
    1
    So where would one go to get assistance with getting this working? I finally have it "loading" via EWA, but there's nothing in the saved folder and this is my first time modding Empyrion besides using EAH.
     
    #2
  3. ASTIC

    ASTIC Rear Admiral

    Joined:
    Dec 11, 2016
    Messages:
    1,094
    Likes Received:
    735
    You can download the mod package here
    https://github.com/GitHub-TC/EmpyrionModPackage
    You can download all working mods in one package here - just unzip it into your ...\Content\Mods folder
    after a start you only need to configure them in the savegame directory
     
    #3
  4. Puck

    Puck Ensign

    Joined:
    Nov 17, 2024
    Messages:
    5
    Likes Received:
    1
    So I've started and stopped numerous times, when stopped I edit the config file, save and start server and / or mod, and it wipes the config every time. I'm not sure what I'm doing wrong but I'm getting frustrated, but on the positive side, I actually get the \discord help to show up - just says offline always, but it's further than I was before.

    I don't know what's going on - when I click on the cogwheel for the mod, just a blank page. The console shows lots of errors, and don't know why. I'll attach images if it lets me:
    (Puck removed images)
     
    #4
    Last edited: Nov 19, 2024
  5. ASTIC

    ASTIC Rear Admiral

    Joined:
    Dec 11, 2016
    Messages:
    1,094
    Likes Received:
    735
    I didn't finish programming the function to edit the configuration of the mods directly from the EWA back then - and unfortunately I didn't expand it either :-(

    You have to stop the mods and then edit the configurations in the savegame via FTP and editor and then start the mods again - the EGS server can continue to run during this time
     
    #5
  6. Puck

    Puck Ensign

    Joined:
    Nov 17, 2024
    Messages:
    5
    Likes Received:
    1
    ok, so I figured out what my issue was - there has to be "quotes" around the channel names. Now I see text from game to discord, but discord to game isn't working right now - so it's at least a start.
     
    #6
    ASTIC likes this.
  7. Puck

    Puck Ensign

    Joined:
    Nov 17, 2024
    Messages:
    5
    Likes Received:
    1
    ok, so chat seems to be working 2 way for everyone but myself. I think it's because my discord name is Puck1337 vs what's in game of Puck. I've tried to type "init" on both sides and nothing, this is the last thing I think that needs to get fixed.... thoughts?
     
    #7
  8. ASTIC

    ASTIC Rear Admiral

    Joined:
    Dec 11, 2016
    Messages:
    1,094
    Likes Received:
    735
    can you change your discord DISPLAY-name to "Puck" e.g. here mine is called ASTIC.

    [​IMG]

    Otherwise we would have to include an ALIAS list in the mod, which is (time-consuming) to maintain
     
    #8
  9. Puck

    Puck Ensign

    Joined:
    Nov 17, 2024
    Messages:
    5
    Likes Received:
    1
    Yeah, I updated my display name, now I just gotta wait for the server to be empty so I can restart everything to see if that helps with my chat. thank you for the help - appreciate it.
     
    #9
  10. ASTIC

    ASTIC Rear Admiral

    Joined:
    Dec 11, 2016
    Messages:
    1,094
    Likes Received:
    735
    You can also stop and start the mods during operation - simply via the EWA
     
    #10

Share This Page