matrix-puppeteer-line/matrix_puppeteer_line/config.py
Andrew Ferrazzutti 6d646e082b Inbound sync & sticker improvements
- Handle "decrypting" state of messages
- Handle lazy loading of emoji
- Better handle lazy loading of images/stickers
- Improve reliability of message sending, especially when sending
  several messages quickly
- Use m.sticker events for inbound stickers instead of m.image, and add
  a config to optionally use m.image if desired
- Use proper sizing for emoji, and add config to scale them since they
  are somewhat small
- Deduplicate stickers as best as possible (works until they get a
  different blob URL)
- Add config to disable bridging stickers/emoji
- Send m.notice for inbound messages of unknown type
2021-06-06 18:15:38 -04:00

88 lines
3.4 KiB
Python

# matrix-puppeteer-line - A very hacky Matrix-LINE bridge based on running LINE's Chrome extension in Puppeteer
# Copyright (C) 2020-2021 Tulir Asokan, Andrew Ferrazzutti
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
from typing import Any, List, NamedTuple
import os
from mautrix.util.config import ConfigUpdateHelper, ForbiddenDefault
from mautrix.bridge.config import BaseBridgeConfig
Permissions = NamedTuple("Permissions", user=bool, admin=bool, level=str)
class Config(BaseBridgeConfig):
def __getitem__(self, key: str) -> Any:
try:
return os.environ[f"matrix_puppeteer_line_{key.replace('.', '_').upper()}"]
except KeyError:
return super().__getitem__(key)
@property
def forbidden_defaults(self) -> List[ForbiddenDefault]:
return [
*super().forbidden_defaults,
ForbiddenDefault("appservice.database", "postgres://username:password@hostname/db"),
ForbiddenDefault("bridge.user", "@admin:example.com"),
]
def do_update(self, helper: ConfigUpdateHelper) -> None:
super().do_update(helper)
copy, copy_dict, base = helper
copy("appservice.provisioning.enabled")
copy("appservice.provisioning.prefix")
copy("appservice.provisioning.shared_secret")
if base["appservice.provisioning.shared_secret"] == "generate":
base["appservice.provisioning.shared_secret"] = self._new_token()
copy("appservice.community_id")
copy("metrics.enabled")
copy("metrics.listen_port")
copy("bridge.username_template")
copy("bridge.displayname_template")
copy("bridge.displayname_max_length")
copy("bridge.initial_conversation_sync")
copy("bridge.invite_own_puppet_to_pm")
copy("bridge.login_shared_secret")
copy("bridge.federate_rooms")
copy("bridge.backfill.invite_own_puppet")
copy("bridge.backfill.initial_limit")
copy("bridge.backfill.disable_notifications")
copy("bridge.encryption.allow")
copy("bridge.encryption.default")
copy("bridge.encryption.key_sharing.allow")
copy("bridge.encryption.key_sharing.require_cross_signing")
copy("bridge.encryption.key_sharing.require_verification")
copy("bridge.private_chat_portal_meta")
copy("bridge.delivery_receipts")
copy("bridge.delivery_error_reports")
copy("bridge.resend_bridge_info")
copy("bridge.receive_stickers")
copy("bridge.use_sticker_events")
copy("bridge.emoji_scale_factor")
copy("bridge.command_prefix")
copy("bridge.user")
copy("puppeteer.connection.type")
if base["puppeteer.connection.type"] == "unix":
copy("puppeteer.connection.path")
else:
copy("puppeteer.connection.host")
copy("puppeteer.connection.port")