Serge Bazanski | de62751 | 2020-08-24 21:17:55 +0000 | [diff] [blame] | 1 | # Homeserver details |
| 2 | homeserver: |
| 3 | # The address that this appservice can use to connect to the homeserver. |
| 4 | address: https://example.com |
| 5 | # The domain of the homeserver (for MXIDs, etc). |
| 6 | domain: example.com |
| 7 | # Whether or not to verify the SSL certificate of the homeserver. |
| 8 | # Only applies if address starts with https:// |
| 9 | verify_ssl: true |
| 10 | |
| 11 | # Application service host/registration related details |
| 12 | # Changing these values requires regeneration of the registration. |
| 13 | appservice: |
| 14 | # The address that the homeserver can use to connect to this appservice. |
| 15 | address: http://localhost:29317 |
| 16 | # When using https:// the TLS certificate and key files for the address. |
| 17 | tls_cert: false |
| 18 | tls_key: false |
| 19 | |
| 20 | # The hostname and port where this appservice should listen. |
| 21 | hostname: 0.0.0.0 |
| 22 | port: 29317 |
| 23 | # The maximum body size of appservice API requests (from the homeserver) in mebibytes |
| 24 | # Usually 1 is enough, but on high-traffic bridges you might need to increase this to avoid 413s |
| 25 | max_body_size: 1 |
| 26 | |
| 27 | # The full URI to the database. SQLite and Postgres are fully supported. |
| 28 | # Other DBMSes supported by SQLAlchemy may or may not work. |
| 29 | # Format examples: |
| 30 | # SQLite: sqlite:///filename.db |
| 31 | # Postgres: postgres://username:password@hostname/dbname |
| 32 | database: sqlite:////data/mautrix-telegram.db |
| 33 | |
| 34 | # Public part of web server for out-of-Matrix interaction with the bridge. |
| 35 | # Used for things like login if the user wants to make sure the 2FA password isn't stored in |
| 36 | # the HS database. |
| 37 | public: |
| 38 | # Whether or not the public-facing endpoints should be enabled. |
| 39 | enabled: false |
| 40 | # The prefix to use in the public-facing endpoints. |
| 41 | prefix: /public |
| 42 | # The base URL where the public-facing endpoints are available. The prefix is not added |
| 43 | # implicitly. |
| 44 | external: https://example.com/public |
| 45 | |
| 46 | # Provisioning API part of the web server for automated portal creation and fetching information. |
| 47 | # Used by things like Dimension (https://dimension.t2bot.io/). |
| 48 | provisioning: |
| 49 | # Whether or not the provisioning API should be enabled. |
| 50 | enabled: true |
| 51 | # The prefix to use in the provisioning API endpoints. |
| 52 | prefix: /_matrix/provision/v1 |
| 53 | # The shared secret to authorize users of the API. |
| 54 | # Set to "generate" to generate and save a new token. |
| 55 | shared_secret: hackmehackmehackme |
| 56 | |
| 57 | # The unique ID of this appservice. |
| 58 | id: telegram |
| 59 | # Username of the appservice bot. |
| 60 | bot_username: telegrambot |
| 61 | # Display name and avatar for bot. Set to "remove" to remove display name/avatar, leave empty |
| 62 | # to leave display name/avatar as-is. |
| 63 | bot_displayname: Telegram bridge bot |
| 64 | bot_avatar: mxc://maunium.net/tJCRmUyJDsgRNgqhOgoiHWbX |
| 65 | |
| 66 | # Community ID for bridged users (changes registration file) and rooms. |
| 67 | # Must be created manually. |
| 68 | # |
| 69 | # Example: "+telegram:example.com". Set to false to disable. |
| 70 | community_id: false |
| 71 | |
| 72 | # Authentication tokens for AS <-> HS communication. Autogenerated; do not modify. |
| 73 | as_token: This value is generated when generating the registration |
| 74 | hs_token: This value is generated when generating the registration |
| 75 | |
| 76 | # Prometheus telemetry config. Requires prometheus-client to be installed. |
| 77 | metrics: |
| 78 | enabled: false |
| 79 | listen_port: 8000 |
| 80 | |
| 81 | # Manhole config. |
| 82 | manhole: |
| 83 | # Whether or not opening the manhole is allowed. |
| 84 | enabled: false |
| 85 | # The path for the unix socket. |
| 86 | path: /var/tmp/mautrix-telegram.manhole |
| 87 | # The list of UIDs who can be added to the whitelist. |
| 88 | # If empty, any UIDs can be specified in the open-manhole command. |
| 89 | whitelist: |
| 90 | - 0 |
| 91 | |
| 92 | # Bridge config |
| 93 | bridge: |
| 94 | # Localpart template of MXIDs for Telegram users. |
| 95 | # {userid} is replaced with the user ID of the Telegram user. |
| 96 | username_template: telegram_{userid} |
| 97 | # Localpart template of room aliases for Telegram portal rooms. |
| 98 | # {groupname} is replaced with the name part of the public channel/group invite link ( https://t.me/{} ) |
| 99 | alias_template: telegram_{groupname} |
| 100 | # Displayname template for Telegram users. |
| 101 | # {displayname} is replaced with the display name of the Telegram user. |
| 102 | displayname_template: '{displayname} (Telegram)' |
| 103 | |
| 104 | # Set the preferred order of user identifiers which to use in the Matrix puppet display name. |
| 105 | # In the (hopefully unlikely) scenario that none of the given keys are found, the numeric user |
| 106 | # ID is used. |
| 107 | # |
| 108 | # If the bridge is working properly, a phone number or an username should always be known, but |
| 109 | # the other one can very well be empty. |
| 110 | # |
| 111 | # Valid keys: |
| 112 | # "full name" (First and/or last name) |
| 113 | # "full name reversed" (Last and/or first name) |
| 114 | # "first name" |
| 115 | # "last name" |
| 116 | # "username" |
| 117 | # "phone number" |
| 118 | displayname_preference: |
| 119 | - full name |
| 120 | - username |
| 121 | - phone number |
| 122 | # Maximum length of displayname |
| 123 | displayname_max_length: 100 |
| 124 | # Remove avatars from Telegram ghost users when removed on Telegram. This is disabled by default |
| 125 | # as there's no way to determine whether an avatar is removed or just hidden from some users. If |
| 126 | # you're on a single-user instance, this should be safe to enable. |
| 127 | allow_avatar_remove: false |
| 128 | |
| 129 | # Maximum number of members to sync per portal when starting up. Other members will be |
| 130 | # synced when they send messages. The maximum is 10000, after which the Telegram server |
| 131 | # will not send any more members. |
| 132 | # Defaults to no local limit (-> limited to 10000 by server) |
| 133 | max_initial_member_sync: 100 |
| 134 | # Whether or not to sync the member list in channels. |
| 135 | # If no channel admins have logged into the bridge, the bridge won't be able to sync the member |
| 136 | # list regardless of this setting. |
| 137 | sync_channel_members: true |
| 138 | # Whether or not to skip deleted members when syncing members. |
| 139 | skip_deleted_members: true |
| 140 | # Whether or not to automatically synchronize contacts and chats of Matrix users logged into |
| 141 | # their Telegram account at startup. |
| 142 | startup_sync: true |
| 143 | # Number of most recently active dialogs to check when syncing chats. |
| 144 | # Set to 0 to remove limit. |
| 145 | sync_dialog_limit: 30 |
| 146 | # Whether or not to sync and create portals for direct chats at startup. |
| 147 | sync_direct_chats: false |
| 148 | # The maximum number of simultaneous Telegram deletions to handle. |
| 149 | # A large number of simultaneous redactions could put strain on your homeserver. |
| 150 | max_telegram_delete: 10 |
| 151 | # Whether or not to automatically sync the Matrix room state (mostly unpuppeted displaynames) |
| 152 | # at startup and when creating a bridge. |
| 153 | sync_matrix_state: true |
| 154 | # Allow logging in within Matrix. If false, the only way to log in is using the out-of-Matrix |
| 155 | # login website (see appservice.public config section) |
| 156 | allow_matrix_login: true |
| 157 | # Whether or not to bridge plaintext highlights. |
| 158 | # Only enable this if your displayname_template has some static part that the bridge can use to |
| 159 | # reliably identify what is a plaintext highlight. |
| 160 | plaintext_highlights: false |
| 161 | # Whether or not to make portals of publicly joinable channels/supergroups publicly joinable on Matrix. |
| 162 | public_portals: true |
| 163 | # Whether or not to use /sync to get presence, read receipts and typing notifications when using |
| 164 | # your own Matrix account as the Matrix puppet for your Telegram account. |
| 165 | sync_with_custom_puppets: true |
| 166 | # Shared secret for https://github.com/devture/matrix-synapse-shared-secret-auth |
| 167 | # |
| 168 | # If set, custom puppets will be enabled automatically for local users |
| 169 | # instead of users having to find an access token and run `login-matrix` |
| 170 | # manually. |
| 171 | login_shared_secret: |
| 172 | # Set to false to disable link previews in messages sent to Telegram. |
| 173 | telegram_link_preview: true |
| 174 | # Use inline images instead of a separate message for the caption. |
| 175 | # N.B. Inline images are not supported on all clients (e.g. Riot iOS). |
| 176 | inline_images: false |
| 177 | # Maximum size of image in megabytes before sending to Telegram as a document. |
| 178 | image_as_file_size: 10 |
| 179 | # Maximum size of Telegram documents in megabytes to bridge. |
| 180 | max_document_size: 100 |
| 181 | # Enable experimental parallel file transfer, which makes uploads/downloads much faster by |
| 182 | # streaming from/to Matrix and using many connections for Telegram. |
| 183 | # Note that generating HQ thumbnails for videos is not possible with streamed transfers. |
| 184 | parallel_file_transfer: false |
| 185 | # Whether or not created rooms should have federation enabled. |
| 186 | # If false, created portal rooms will never be federated. |
| 187 | federate_rooms: true |
| 188 | # Settings for converting animated stickers. |
| 189 | animated_sticker: |
| 190 | # Format to which animated stickers should be converted. |
| 191 | # disable - No conversion, send as-is (gzipped lottie) |
| 192 | # png - converts to non-animated png (fastest), |
| 193 | # gif - converts to animated gif, but loses transparency |
| 194 | # webm - converts to webm video, requires ffmpeg executable with vp9 codec and webm container support |
| 195 | target: gif |
| 196 | # Arguments for converter. All converters take width and height. |
| 197 | # GIF converter takes background as a hex color. |
| 198 | args: |
| 199 | width: 256 |
| 200 | height: 256 |
| 201 | background: '020202' # only for gif |
| 202 | fps: 30 # only for webm |
| 203 | # End-to-bridge encryption support options. These require matrix-nio to be installed with pip |
| 204 | # and login_shared_secret to be configured in order to get a device for the bridge bot. |
| 205 | # |
| 206 | # Additionally, https://github.com/matrix-org/synapse/pull/5758 is required if using a normal |
| 207 | # application service. |
| 208 | encryption: |
| 209 | # Allow encryption, work in group chat rooms with e2ee enabled |
| 210 | allow: false |
| 211 | # Default to encryption, force-enable encryption in all portals the bridge creates |
| 212 | # This will cause the bridge bot to be in private chats for the encryption to work properly. |
| 213 | default: false |
| 214 | # Whether or not to explicitly set the avatar and room name for private |
| 215 | # chat portal rooms. This will be implicitly enabled if encryption.default is true. |
| 216 | private_chat_portal_meta: false |
| 217 | # Whether or not the bridge should send a read receipt from the bridge bot when a message has |
| 218 | # been sent to Telegram. |
| 219 | delivery_receipts: false |
| 220 | # Whether or not delivery errors should be reported as messages in the Matrix room. |
| 221 | delivery_error_reports: false |
| 222 | |
| 223 | # Overrides for base power levels. |
| 224 | initial_power_level_overrides: |
| 225 | user: {} |
| 226 | group: {} |
| 227 | |
| 228 | # Whether to bridge Telegram bot messages as m.notices or m.texts. |
| 229 | bot_messages_as_notices: true |
| 230 | bridge_notices: |
| 231 | # Whether or not Matrix bot messages (type m.notice) should be bridged. |
| 232 | default: false |
| 233 | # List of user IDs for whom the previous flag is flipped. |
| 234 | # e.g. if bridge_notices.default is false, notices from other users will not be bridged, but |
| 235 | # notices from users listed here will be bridged. |
| 236 | exceptions: |
| 237 | - '@importantbot:example.com' |
| 238 | |
| 239 | # Some config options related to Telegram message deduplication. |
| 240 | # The default values are usually fine, but some debug messages/warnings might recommend you |
| 241 | # change these. |
| 242 | deduplication: |
| 243 | # Whether or not to check the database if the message about to be sent is a duplicate. |
| 244 | pre_db_check: false |
| 245 | # The number of latest events to keep when checking for duplicates. |
| 246 | # You might need to increase this on high-traffic bridge instances. |
| 247 | cache_queue_length: 20 |
| 248 | |
| 249 | # The formats to use when sending messages to Telegram via the relay bot. |
| 250 | # Text msgtypes (m.text, m.notice and m.emote) support HTML, media msgtypes don't. |
| 251 | # |
| 252 | # Available variables: |
| 253 | # $sender_displayname - The display name of the sender (e.g. Example User) |
| 254 | # $sender_username - The username (Matrix ID localpart) of the sender (e.g. exampleuser) |
| 255 | # $sender_mxid - The Matrix ID of the sender (e.g. @exampleuser:example.com) |
| 256 | # $message - The message content |
| 257 | message_formats: |
| 258 | m.text: '<b>$sender_displayname</b>: $message' |
| 259 | m.notice: '<b>$sender_displayname</b>: $message' |
| 260 | m.emote: '* <b>$sender_displayname</b> $message' |
| 261 | m.file: '<b>$sender_displayname</b> sent a file: $message' |
| 262 | m.image: '<b>$sender_displayname</b> sent an image: $message' |
| 263 | m.audio: '<b>$sender_displayname</b> sent an audio file: $message' |
| 264 | m.video: '<b>$sender_displayname</b> sent a video: $message' |
| 265 | m.location: '<b>$sender_displayname</b> sent a location: $message' |
| 266 | # Telegram doesn't have built-in emotes, this field specifies how m.emote's from authenticated |
| 267 | # users are sent to telegram. All fields in message_formats are supported. Additionally, the |
| 268 | # Telegram user info is available in the following variables: |
| 269 | # $displayname - Telegram displayname |
| 270 | # $username - Telegram username (may not exist) |
| 271 | # $mention - Telegram @username or displayname mention (depending on which exists) |
| 272 | emote_format: '* $mention $formatted_body' |
| 273 | |
| 274 | # The formats to use when sending state events to Telegram via the relay bot. |
| 275 | # |
| 276 | # Variables from `message_formats` that have the `sender_` prefix are available without the prefix. |
| 277 | # In name_change events, `$prev_displayname` is the previous displayname. |
| 278 | # |
| 279 | # Set format to an empty string to disable the messages for that event. |
| 280 | state_event_formats: |
| 281 | join: <b>$displayname</b> joined the room. |
| 282 | leave: <b>$displayname</b> left the room. |
| 283 | name_change: <b>$prev_displayname</b> changed their name to <b>$displayname</b> |
| 284 | |
| 285 | # Filter rooms that can/can't be bridged. Can also be managed using the `filter` and |
| 286 | # `filter-mode` management commands. |
| 287 | # |
| 288 | # Filters do not affect direct chats. |
| 289 | # An empty blacklist will essentially disable the filter. |
| 290 | filter: |
| 291 | # Filter mode to use. Either "blacklist" or "whitelist". |
| 292 | # If the mode is "blacklist", the listed chats will never be bridged. |
| 293 | # If the mode is "whitelist", only the listed chats can be bridged. |
| 294 | mode: blacklist |
| 295 | # The list of group/channel IDs to filter. |
| 296 | list: [] |
| 297 | |
| 298 | # The prefix for commands. Only required in non-management rooms. |
| 299 | command_prefix: '!tg' |
| 300 | |
| 301 | # Permissions for using the bridge. |
| 302 | # Permitted values: |
| 303 | # relaybot - Only use the bridge via the relaybot, no access to commands. |
| 304 | # user - Relaybot level + access to commands to create bridges. |
| 305 | # puppeting - User level + logging in with a Telegram account. |
| 306 | # full - Full access to use the bridge, i.e. previous levels + Matrix login. |
| 307 | # admin - Full access to use the bridge and some extra administration commands. |
| 308 | # Permitted keys: |
| 309 | # * - All Matrix users |
| 310 | # domain - All users on that homeserver |
| 311 | # mxid - Specific user |
| 312 | permissions: |
| 313 | '*': relaybot |
| 314 | public.example.com: user |
| 315 | example.com: full |
| 316 | '@admin:example.com': admin |
| 317 | relaybot: |
| 318 | private_chat: |
| 319 | # List of users to invite to the portal when someone starts a private chat with the bot. |
| 320 | # If empty, private chats with the bot won't create a portal. |
| 321 | invite: [] |
| 322 | # Whether or not to bridge state change messages in relaybot private chats. |
| 323 | state_changes: true |
| 324 | # When private_chat_invite is empty, this message is sent to users /starting the |
| 325 | # relaybot. Telegram's "markdown" is supported. |
| 326 | message: This is a Matrix bridge relaybot and does not support direct chats |
| 327 | # List of users to invite to all group chat portals created by the bridge. |
| 328 | group_chat_invite: [] |
| 329 | # Whether or not the relaybot should not bridge events in unbridged group chats. |
| 330 | # If false, portals will be created when the relaybot receives messages, just like normal |
| 331 | # users. This behavior is usually not desirable, as it interferes with manually bridging |
| 332 | # the chat to another room. |
| 333 | ignore_unbridged_group_chat: true |
| 334 | # Whether or not to allow creating portals from Telegram. |
| 335 | authless_portals: true |
| 336 | # Whether or not to allow Telegram group admins to use the bot commands. |
| 337 | whitelist_group_admins: true |
| 338 | # Whether or not to ignore incoming events sent by the relay bot. |
| 339 | ignore_own_incoming_events: true |
| 340 | # List of usernames/user IDs who are also allowed to use the bot commands. |
| 341 | whitelist: |
| 342 | - myusername |
| 343 | - 12345678 |
| 344 | |
| 345 | # Telegram config |
| 346 | telegram: |
| 347 | # Get your own API keys at https://my.telegram.org/apps |
| 348 | api_id: 12345 |
| 349 | api_hash: tjyd5yge35lbodk1xwzw2jstp90k55qz |
| 350 | # (Optional) Create your own bot at https://t.me/BotFather |
| 351 | bot_token: disabled |
| 352 | |
| 353 | # Telethon connection options. |
| 354 | connection: |
| 355 | # The timeout in seconds to be used when connecting. |
| 356 | timeout: 120 |
| 357 | # How many times the reconnection should retry, either on the initial connection or when |
| 358 | # Telegram disconnects us. May be set to a negative or null value for infinite retries, but |
| 359 | # this is not recommended, since the program can get stuck in an infinite loop. |
| 360 | retries: 5 |
| 361 | # The delay in seconds to sleep between automatic reconnections. |
| 362 | retry_delay: 1 |
| 363 | # The threshold below which the library should automatically sleep on flood wait errors |
| 364 | # (inclusive). For instance, if a FloodWaitError for 17s occurs and flood_sleep_threshold |
| 365 | # is 20s, the library will sleep automatically. If the error was for 21s, it would raise |
| 366 | # the error instead. Values larger than a day (86400) will be changed to a day. |
| 367 | flood_sleep_threshold: 60 |
| 368 | # How many times a request should be retried. Request are retried when Telegram is having |
| 369 | # internal issues, when there is a FloodWaitError less than flood_sleep_threshold, or when |
| 370 | # there's a migrate error. May take a negative or null value for infinite retries, but this |
| 371 | # is not recommended, since some requests can always trigger a call fail (such as searching |
| 372 | # for messages). |
| 373 | request_retries: 5 |
| 374 | |
| 375 | # Device info sent to Telegram. |
| 376 | device_info: |
| 377 | # "auto" = OS name+version. |
| 378 | device_model: auto |
| 379 | # "auto" = Telethon version. |
| 380 | system_version: auto |
| 381 | # "auto" = mautrix-telegram version. |
| 382 | app_version: auto |
| 383 | lang_code: en |
| 384 | system_lang_code: en |
| 385 | |
| 386 | # Custom server to connect to. |
| 387 | server: |
| 388 | # Set to true to use these server settings. If false, will automatically |
| 389 | # use production server assigned by Telegram. Set to false in production. |
| 390 | enabled: false |
| 391 | # The DC ID to connect to. |
| 392 | dc: 2 |
| 393 | # The IP to connect to. |
| 394 | ip: 149.154.167.40 |
| 395 | # The port to connect to. 443 may not work, 80 is better and both are equally secure. |
| 396 | port: 80 |
| 397 | |
| 398 | # Telethon proxy configuration. |
| 399 | # You must install PySocks from pip for proxies to work. |
| 400 | proxy: |
| 401 | # Allowed types: disabled, socks4, socks5, http, mtproxy |
| 402 | type: disabled |
| 403 | # Proxy IP address and port. |
| 404 | address: 127.0.0.1 |
| 405 | port: 1080 |
| 406 | # Whether or not to perform DNS resolving remotely. Only for socks/http proxies. |
| 407 | rdns: true |
| 408 | # Proxy authentication (optional). Put MTProxy secret in password field. |
| 409 | username: '' |
| 410 | password: '' |
| 411 | |
| 412 | # Python logging configuration. |
| 413 | # |
| 414 | # See section 16.7.2 of the Python documentation for more info: |
| 415 | # https://docs.python.org/3.6/library/logging.config.html#configuration-dictionary-schema |
| 416 | logging: |
| 417 | version: 1 |
| 418 | formatters: |
| 419 | colored: |
| 420 | (): mautrix_telegram.util.ColorFormatter |
| 421 | format: '[%(asctime)s] [%(levelname)s@%(name)s] %(message)s' |
| 422 | normal: |
| 423 | format: '[%(asctime)s] [%(levelname)s@%(name)s] %(message)s' |
| 424 | handlers: |
| 425 | file: |
| 426 | class: logging.handlers.RotatingFileHandler |
| 427 | formatter: normal |
| 428 | filename: ./mautrix-telegram.log |
| 429 | maxBytes: 10485760 |
| 430 | backupCount: 10 |
| 431 | console: |
| 432 | class: logging.StreamHandler |
| 433 | formatter: colored |
| 434 | loggers: |
| 435 | mau: |
| 436 | level: DEBUG |
| 437 | telethon: |
| 438 | level: INFO |
| 439 | aiohttp: |
| 440 | level: INFO |
| 441 | root: |
| 442 | level: DEBUG |
| 443 | handlers: [file, console] |