example-config.yaml 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. # Homeserver details.
  2. homeserver:
  3. # The address that this appservice can use to connect to the homeserver.
  4. address: https://matrix.example.com
  5. # Publicly accessible base URL for media, used for avatars in relay mode.
  6. # If not set, the connection address above will be used.
  7. public_address: null
  8. # The domain of the homeserver (also known as server_name, used for MXIDs, etc).
  9. domain: example.com
  10. # What software is the homeserver running?
  11. # Standard Matrix homeservers like Synapse, Dendrite and Conduit should just use "standard" here.
  12. software: standard
  13. # The URL to push real-time bridge status to.
  14. # If set, the bridge will make POST requests to this URL whenever a user's discord connection state changes.
  15. # The bridge will use the appservice as_token to authorize requests.
  16. status_endpoint: null
  17. # Endpoint for reporting per-message status.
  18. message_send_checkpoint_endpoint: null
  19. # Does the homeserver support https://github.com/matrix-org/matrix-spec-proposals/pull/2246?
  20. async_media: false
  21. # Application service host/registration related details.
  22. # Changing these values requires regeneration of the registration.
  23. appservice:
  24. # The address that the homeserver can use to connect to this appservice.
  25. address: http://localhost:29334
  26. # The hostname and port where this appservice should listen.
  27. hostname: 0.0.0.0
  28. port: 29334
  29. # Database config.
  30. database:
  31. # The database type. "sqlite3-fk-wal" and "postgres" are supported.
  32. type: postgres
  33. # The database URI.
  34. # SQLite: A raw file path is supported, but `file:<path>?_txlock=immediate` is recommended.
  35. # https://github.com/mattn/go-sqlite3#connection-string
  36. # Postgres: Connection string. For example, postgres://user:password@host/database?sslmode=disable
  37. # To connect via Unix socket, use something like postgres:///dbname?host=/var/run/postgresql
  38. uri: postgres://user:password@host/database?sslmode=disable
  39. # Maximum number of connections. Mostly relevant for Postgres.
  40. max_open_conns: 20
  41. max_idle_conns: 2
  42. # Maximum connection idle time and lifetime before they're closed. Disabled if null.
  43. # Parsed with https://pkg.go.dev/time#ParseDuration
  44. max_conn_idle_time: null
  45. max_conn_lifetime: null
  46. # The unique ID of this appservice.
  47. id: discord
  48. # Appservice bot details.
  49. bot:
  50. # Username of the appservice bot.
  51. username: discordbot
  52. # Display name and avatar for bot. Set to "remove" to remove display name/avatar, leave empty
  53. # to leave display name/avatar as-is.
  54. displayname: Discord bridge bot
  55. avatar: mxc://maunium.net/nIdEykemnwdisvHbpxflpDlC
  56. # Whether or not to receive ephemeral events via appservice transactions.
  57. # Requires MSC2409 support (i.e. Synapse 1.22+).
  58. ephemeral_events: true
  59. # Should incoming events be handled asynchronously?
  60. # This may be necessary for large public instances with lots of messages going through.
  61. # However, messages will not be guaranteed to be bridged in the same order they were sent in.
  62. async_transactions: false
  63. # Authentication tokens for AS <-> HS communication. Autogenerated; do not modify.
  64. as_token: "This value is generated when generating the registration"
  65. hs_token: "This value is generated when generating the registration"
  66. # Bridge config
  67. bridge:
  68. # Localpart template of MXIDs for Discord users.
  69. # {{.}} is replaced with the internal ID of the Discord user.
  70. username_template: discord_{{.}}
  71. # Displayname template for Discord users. This is also used as the room name in DMs if private_chat_portal_meta is enabled.
  72. # Available variables:
  73. # .ID - Internal user ID
  74. # .Username - Legacy display/username on Discord
  75. # .GlobalName - New displayname on Discord
  76. # .Discriminator - The 4 numbers after the name on Discord
  77. # .Bot - Whether the user is a bot
  78. # .System - Whether the user is an official system user
  79. # .Webhook - Whether the user is a webhook
  80. displayname_template: '{{or .GlobalName .Username}}{{if .Bot}} (bot){{end}}'
  81. # Displayname template for Discord channels (bridged as rooms, or spaces when type=4).
  82. # Available variables:
  83. # .Name - Channel name, or user displayname (pre-formatted with displayname_template) in DMs.
  84. # .ParentName - Parent channel name (used for categories).
  85. # .GuildName - Guild name.
  86. # .NSFW - Whether the channel is marked as NSFW.
  87. # .Type - Channel type (see values at https://github.com/bwmarrin/discordgo/blob/v0.25.0/structs.go#L251-L267)
  88. channel_name_template: '{{if or (eq .Type 3) (eq .Type 4)}}{{.Name}}{{else}}#{{.Name}}{{end}}'
  89. # Displayname template for Discord guilds (bridged as spaces).
  90. # Available variables:
  91. # .Name - Guild name
  92. guild_name_template: '{{.Name}}'
  93. # Whether to explicitly set the avatar and room name for private chat portal rooms.
  94. # If set to `default`, this will be enabled in encrypted rooms and disabled in unencrypted rooms.
  95. # If set to `always`, all DM rooms will have explicit names and avatars set.
  96. # If set to `never`, DM rooms will never have names and avatars set.
  97. private_chat_portal_meta: default
  98. portal_message_buffer: 128
  99. # Number of private channel portals to create on bridge startup.
  100. # Other portals will be created when receiving messages.
  101. startup_private_channel_create_limit: 5
  102. # Should the bridge send a read receipt from the bridge bot when a message has been sent to Discord?
  103. delivery_receipts: false
  104. # Whether the bridge should send the message status as a custom com.beeper.message_send_status event.
  105. message_status_events: false
  106. # Whether the bridge should send error notices via m.notice events when a message fails to bridge.
  107. message_error_notices: true
  108. # Should the bridge use space-restricted join rules instead of invite-only for guild rooms?
  109. # This can avoid unnecessary invite events in guild rooms when members are synced in.
  110. restricted_rooms: true
  111. # Should the bridge automatically join the user to threads on Discord when the thread is opened on Matrix?
  112. # This only works with clients that support thread read receipts (MSC3771 added in Matrix v1.4).
  113. autojoin_thread_on_open: true
  114. # Should inline fields in Discord embeds be bridged as HTML tables to Matrix?
  115. # Tables aren't supported in all clients, but are the only way to emulate the Discord inline field UI.
  116. embed_fields_as_tables: true
  117. # Should guild channels be muted when the portal is created? This only meant for single-user instances,
  118. # it won't mute it for all users if there are multiple Matrix users in the same Discord guild.
  119. mute_channels_on_create: false
  120. # Should the bridge update the m.direct account data event when double puppeting is enabled.
  121. # Note that updating the m.direct event is not atomic (except with mautrix-asmux)
  122. # and is therefore prone to race conditions.
  123. sync_direct_chat_list: false
  124. # Set this to true to tell the bridge to re-send m.bridge events to all rooms on the next run.
  125. # This field will automatically be changed back to false after it, except if the config file is not writable.
  126. resend_bridge_info: false
  127. # Should incoming custom emoji reactions be bridged as mxc:// URIs?
  128. # If set to false, custom emoji reactions will be bridged as the shortcode instead, and the image won't be available.
  129. custom_emoji_reactions: true
  130. # Should the bridge attempt to completely delete portal rooms when a channel is deleted on Discord?
  131. # If true, the bridge will try to kick Matrix users from the room. Otherwise, the bridge only makes ghosts leave.
  132. delete_portal_on_channel_delete: false
  133. # Should the bridge delete all portal rooms when you leave a guild on Discord?
  134. # This only applies if the guild has no other Matrix users on this bridge instance.
  135. delete_guild_on_leave: true
  136. # Whether or not created rooms should have federation enabled.
  137. # If false, created portal rooms will never be federated.
  138. federate_rooms: true
  139. # Prefix messages from webhooks with the profile info? This can be used along with a custom displayname_template
  140. # to better handle webhooks that change their name all the time (like ones used by bridges).
  141. prefix_webhook_messages: false
  142. # Bridge webhook avatars?
  143. enable_webhook_avatars: true
  144. # Should the bridge upload media to the Discord CDN directly before sending the message when using a user token,
  145. # like the official client does? The other option is sending the media in the message send request as a form part
  146. # (which is always used by bots and webhooks).
  147. use_discord_cdn_upload: true
  148. # Should mxc uris copied from Discord be cached?
  149. # This can be `never` to never cache, `unencrypted` to only cache unencrypted mxc uris, or `always` to cache everything.
  150. # If you have a media repo that generates non-unique mxc uris, you should set this to never.
  151. cache_media: unencrypted
  152. # Patterns for converting Discord media to custom mxc:// URIs instead of reuploading.
  153. # Each of the patterns can be set to null to disable custom URIs for that type of media.
  154. # More details can be found at https://docs.mau.fi/bridges/go/discord/direct-media.html
  155. media_patterns:
  156. # Should custom mxc:// URIs be used instead of reuploading media?
  157. enabled: false
  158. # Pattern for normal message attachments.
  159. attachments: mxc://discord-media.mau.dev/attachments|{{.ChannelID}}|{{.AttachmentID}}|{{.FileName}}
  160. # Pattern for custom emojis.
  161. emojis: mxc://discord-media.mau.dev/emojis|{{.ID}}.{{.Ext}}
  162. # Pattern for stickers. Note that animated lottie stickers will not be converted if this is enabled.
  163. stickers: mxc://discord-media.mau.dev/stickers|{{.ID}}.{{.Ext}}
  164. # Pattern for static user avatars.
  165. avatars: mxc://discord-media.mau.dev/avatars|{{.UserID}}|{{.AvatarID}}.{{.Ext}}
  166. # Settings for converting animated stickers.
  167. animated_sticker:
  168. # Format to which animated stickers should be converted.
  169. # disable - No conversion, send as-is (lottie JSON)
  170. # png - converts to non-animated png (fastest)
  171. # gif - converts to animated gif
  172. # webm - converts to webm video, requires ffmpeg executable with vp9 codec and webm container support
  173. # webp - converts to animated webp, requires ffmpeg executable with webp codec/container support
  174. target: webp
  175. # Arguments for converter. All converters take width and height.
  176. args:
  177. width: 320
  178. height: 320
  179. fps: 25 # only for webm, webp and gif (2, 5, 10, 20 or 25 recommended)
  180. # Servers to always allow double puppeting from
  181. double_puppet_server_map:
  182. example.com: https://example.com
  183. # Allow using double puppeting from any server with a valid client .well-known file.
  184. double_puppet_allow_discovery: false
  185. # Shared secrets for https://github.com/devture/matrix-synapse-shared-secret-auth
  186. #
  187. # If set, double puppeting will be enabled automatically for local users
  188. # instead of users having to find an access token and run `login-matrix`
  189. # manually.
  190. login_shared_secret_map:
  191. example.com: foobar
  192. # The prefix for commands. Only required in non-management rooms.
  193. command_prefix: '!discord'
  194. # Messages sent upon joining a management room.
  195. # Markdown is supported. The defaults are listed below.
  196. management_room_text:
  197. # Sent when joining a room.
  198. welcome: "Hello, I'm a Discord bridge bot."
  199. # Sent when joining a management room and the user is already logged in.
  200. welcome_connected: "Use `help` for help."
  201. # Sent when joining a management room and the user is not logged in.
  202. welcome_unconnected: "Use `help` for help or `login` to log in."
  203. # Optional extra text sent when joining a management room.
  204. additional_help: ""
  205. # Settings for backfilling messages.
  206. backfill:
  207. # Limits for forward backfilling.
  208. forward_limits:
  209. # Initial backfill (when creating portal). 0 means backfill is disabled.
  210. # A special unlimited value is not supported, you must set a limit. Initial backfill will
  211. # fetch all messages first before backfilling anything, so high limits can take a lot of time.
  212. initial:
  213. dm: 0
  214. channel: 0
  215. # Missed message backfill (on startup).
  216. # 0 means backfill is disabled, -1 means fetch all messages since last bridged message.
  217. # When using unlimited backfill (-1), messages are backfilled as they are fetched.
  218. # With limits, all messages up to the limit are fetched first and backfilled afterwards.
  219. missed:
  220. dm: 0
  221. channel: 0
  222. # Maximum members in a guild to enable backfilling. Set to -1 to disable limit.
  223. # This can be used as a rough heuristic to disable backfilling in channels that are too active.
  224. # Currently only applies to missed message backfill.
  225. max_guild_members: -1
  226. # End-to-bridge encryption support options.
  227. #
  228. # See https://docs.mau.fi/bridges/general/end-to-bridge-encryption.html for more info.
  229. encryption:
  230. # Allow encryption, work in group chat rooms with e2ee enabled
  231. allow: false
  232. # Default to encryption, force-enable encryption in all portals the bridge creates
  233. # This will cause the bridge bot to be in private chats for the encryption to work properly.
  234. default: false
  235. # Whether to use MSC2409/MSC3202 instead of /sync long polling for receiving encryption-related data.
  236. appservice: false
  237. # Require encryption, drop any unencrypted messages.
  238. require: false
  239. # Enable key sharing? If enabled, key requests for rooms where users are in will be fulfilled.
  240. # You must use a client that supports requesting keys from other users to use this feature.
  241. allow_key_sharing: false
  242. # Should users mentions be in the event wire content to enable the server to send push notifications?
  243. plaintext_mentions: false
  244. # Options for deleting megolm sessions from the bridge.
  245. delete_keys:
  246. # Beeper-specific: delete outbound sessions when hungryserv confirms
  247. # that the user has uploaded the key to key backup.
  248. delete_outbound_on_ack: false
  249. # Don't store outbound sessions in the inbound table.
  250. dont_store_outbound: false
  251. # Ratchet megolm sessions forward after decrypting messages.
  252. ratchet_on_decrypt: false
  253. # Delete fully used keys (index >= max_messages) after decrypting messages.
  254. delete_fully_used_on_decrypt: false
  255. # Delete previous megolm sessions from same device when receiving a new one.
  256. delete_prev_on_new_session: false
  257. # Delete megolm sessions received from a device when the device is deleted.
  258. delete_on_device_delete: false
  259. # Periodically delete megolm sessions when 2x max_age has passed since receiving the session.
  260. periodically_delete_expired: false
  261. # What level of device verification should be required from users?
  262. #
  263. # Valid levels:
  264. # unverified - Send keys to all device in the room.
  265. # cross-signed-untrusted - Require valid cross-signing, but trust all cross-signing keys.
  266. # cross-signed-tofu - Require valid cross-signing, trust cross-signing keys on first use (and reject changes).
  267. # cross-signed-verified - Require valid cross-signing, plus a valid user signature from the bridge bot.
  268. # Note that creating user signatures from the bridge bot is not currently possible.
  269. # verified - Require manual per-device verification
  270. # (currently only possible by modifying the `trust` column in the `crypto_device` database table).
  271. verification_levels:
  272. # Minimum level for which the bridge should send keys to when bridging messages from WhatsApp to Matrix.
  273. receive: unverified
  274. # Minimum level that the bridge should accept for incoming Matrix messages.
  275. send: unverified
  276. # Minimum level that the bridge should require for accepting key requests.
  277. share: cross-signed-tofu
  278. # Options for Megolm room key rotation. These options allow you to
  279. # configure the m.room.encryption event content. See:
  280. # https://spec.matrix.org/v1.3/client-server-api/#mroomencryption for
  281. # more information about that event.
  282. rotation:
  283. # Enable custom Megolm room key rotation settings. Note that these
  284. # settings will only apply to rooms created after this option is
  285. # set.
  286. enable_custom: false
  287. # The maximum number of milliseconds a session should be used
  288. # before changing it. The Matrix spec recommends 604800000 (a week)
  289. # as the default.
  290. milliseconds: 604800000
  291. # The maximum number of messages that should be sent with a given a
  292. # session before changing it. The Matrix spec recommends 100 as the
  293. # default.
  294. messages: 100
  295. # Settings for provisioning API
  296. provisioning:
  297. # Prefix for the provisioning API paths.
  298. prefix: /_matrix/provision
  299. # Shared secret for authentication. If set to "generate", a random secret will be generated,
  300. # or if set to "disable", the provisioning API will be disabled.
  301. shared_secret: generate
  302. # Permissions for using the bridge.
  303. # Permitted values:
  304. # relay - Talk through the relaybot (if enabled), no access otherwise
  305. # user - Access to use the bridge to chat with a Discord account.
  306. # admin - User level and some additional administration tools
  307. # Permitted keys:
  308. # * - All Matrix users
  309. # domain - All users on that homeserver
  310. # mxid - Specific user
  311. permissions:
  312. "*": relay
  313. "example.com": user
  314. "@admin:example.com": admin
  315. # Logging config. See https://github.com/tulir/zeroconfig for details.
  316. logging:
  317. min_level: debug
  318. writers:
  319. - type: stdout
  320. format: pretty-colored
  321. - type: file
  322. format: json
  323. filename: ./logs/mautrix-discord.log
  324. max_size: 100
  325. max_backups: 10
  326. compress: true