example-config.yaml 19 KB

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