Skip to content

Navigation Menu

Sign in
Sign up

Repository files navigation

ChatBridge

This is a fork from TIS ChatBridge, so for a generic use guide, refer to the original repository.

Changes implemented

Makes messages sent from a Minecraft server appear as if they were sent by the Minecraft player inside the discord chatbridge channel:

chatbridge example

The bot uses webhooks to appear as imaginary characters created automatically from a Minecraft IGN.

Next to the MC name, the ChatBridge client where the message was sent from appears between [].

Emote bridge (Discord custom emotes <-> Minecraft)

Custom Discord emotes are translated both ways so they render on each side:

  • Discord -> Minecraft: a <:name:id> (or animated <a:name:id>) becomes the Private Use Area glyph that a server resource pack draws as the emote, so vanilla (no-mod) clients see the real image.
  • Minecraft -> Discord: a :name: shortcode (or the PUA glyph itself) becomes the matching <:name:id> mention, so it shows up as the actual emote in Discord.

The emote table is loaded at startup from an emote_map.json placed in the bot's working directory. See emote_map.example.json for the format ({ "name": {"id": "...", "char": "<PUA glyph>", "animated": false} }). If the file is missing the bridge is simply a no-op. Generating the resource pack and the emote_map.json is handled server-side (see WaveMotes-Server).

How to set up

This ChatBridge modification only needs to be executed as the discord_bot instance.

Additional python libraries

This implementation needs 2 extra python libraries to be installed, which are:

  • pillow: to modify a Minecraft skin image and convert it to a square profile picture with borders
  • imgbbpy: only needed if you host the profile pictures on imgbb instead of your own web server (see avatar_dir below)

Extra config variables

The config file (ChatBridge_discord.json) needs some extra values, which are:

  • webhook_url: Obtained in discord server settings -> Integrations -> Webhooks
  • avatar_dir and avatar_base_url: where the profile pictures are hosted. avatar_dir is a directory the bot writes the .png files into, avatar_base_url is the public URL your web server serves that directory at (for example /srv/avatars and https://example.com/avatars). This is the recommended option: there is no upload quota and nothing leaves your machine.
  • imgbb_key: alternative to the two values above, obtained in imgbb API (needs an account, completely free without need of credit card). Beware that the free key is rate limited: once it starts answering Rate limit reached, no new player gets a profile picture until it resets. If neither option produces an image, the bot falls back to a plain head render from mc-heads.net.
  • send_join_as_player: Boolean to choose if join/leave messages are sent by the bot itself (like in the image above) or by the player, which looks like this:

send join as player

JSON Example

The first time the program is used with the command:

python ChatBridge.pyz discord_bot

will generate a ChatBridge_discord.json if it doesn't find it.

Example of a complete ChatBridge_discord.json configuration:

{
 "aes_key": "ThisIstheSecret", // the common encrypt key
 "name": "MyClientName", // the name of the client
 "password": "MyClientPassword", // the password of the client
 "server_hostname": "127.0.0.1", // the hostname of the server
 "server_port": 30001, // the port of the server
 "bot_token": "your.bot.token.here", // the token of your discord bot
 "webhook_url": "your.discord.server.webhook.url.here", // the URL of your discord server's webhook
 "avatar_dir": "/srv/avatars", // where the profile pictures are written, empty to use imgbb instead
 "avatar_base_url": "https://example.com/avatars", // the public URL of that directory
 "imgbb_key": "your.imgbb.api.key.here", // the API key of your imgbb API v1, only used if avatar_dir is empty
 "send_join_as_player": true, // true if sent by the MC avatar, false if sent by the bot
 "channels_for_command": [ // a list of channels, public commands can be used here
 123400000000000000,
 123450000000000000
 ],
 "channel_for_chat": 123400000000000000, // the channel for chatting and private commands
 "command_prefix": "!!",
 "client_to_query_stats": "MyClient1", // it should be a client as an MCDR plugin, with stats_helper plugin installed in the MCDR
 "client_to_query_online": "MyClient2", // a client described in the following section "Client to respond online command"
 "embed_icon_url": "https://cdn.discordapp.com/emojis/566212479487836160.png", // icon that will appear on embed messages (like !!online)
 "server_display_name": "TIS" // name that will appear on embed messages (like !!online)
}

About

improved version of TIS ChatBridge bot discord messages

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

AltStyle によって変換されたページ (->オリジナル) /