Update mautrix-python
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
# mautrix-telegram - A Matrix-Telegram puppeting bridge
|
# mautrix-telegram - A Matrix-Telegram puppeting bridge
|
||||||
# Copyright (C) 2019 Tulir Asokan
|
# Copyright (C) 2021 Tulir Asokan
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU Affero General Public License as published by
|
||||||
@@ -14,6 +14,7 @@
|
|||||||
# You should have received a copy of the GNU Affero General Public License
|
# 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/>.
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
from typing import Dict, Any
|
from typing import Dict, Any
|
||||||
|
import sys
|
||||||
|
|
||||||
from telethon import __version__ as __telethon_version__
|
from telethon import __version__ as __telethon_version__
|
||||||
from alchemysession import AlchemySessionContainer
|
from alchemysession import AlchemySessionContainer
|
||||||
@@ -21,6 +22,7 @@ from alchemysession import AlchemySessionContainer
|
|||||||
from mautrix.types import UserID, RoomID
|
from mautrix.types import UserID, RoomID
|
||||||
from mautrix.bridge import Bridge
|
from mautrix.bridge import Bridge
|
||||||
from mautrix.util.db import Base
|
from mautrix.util.db import Base
|
||||||
|
from mautrix.bridge.state_store.sqlalchemy import SQLBridgeStateStore
|
||||||
|
|
||||||
from .web.provisioning import ProvisioningAPI
|
from .web.provisioning import ProvisioningAPI
|
||||||
from .web.public import PublicBridgeWebsite
|
from .web.public import PublicBridgeWebsite
|
||||||
@@ -36,6 +38,9 @@ from .puppet import Puppet, init as init_puppet
|
|||||||
from .user import User, init as init_user
|
from .user import User, init as init_user
|
||||||
from .version import version, linkified_version
|
from .version import version, linkified_version
|
||||||
|
|
||||||
|
import sqlalchemy as sql
|
||||||
|
from sqlalchemy.engine.base import Engine
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import prometheus_client as prometheus
|
import prometheus_client as prometheus
|
||||||
except ImportError:
|
except ImportError:
|
||||||
@@ -53,18 +58,32 @@ class TelegramBridge(Bridge):
|
|||||||
markdown_version = linkified_version
|
markdown_version = linkified_version
|
||||||
config_class = Config
|
config_class = Config
|
||||||
matrix_class = MatrixHandler
|
matrix_class = MatrixHandler
|
||||||
|
state_store_class = SQLBridgeStateStore
|
||||||
|
|
||||||
|
db: 'Engine'
|
||||||
config: Config
|
config: Config
|
||||||
session_container: AlchemySessionContainer
|
session_container: AlchemySessionContainer
|
||||||
bot: Bot
|
bot: Bot
|
||||||
|
|
||||||
def prepare_db(self) -> None:
|
def prepare_db(self) -> None:
|
||||||
super().prepare_db()
|
if not sql:
|
||||||
|
raise RuntimeError("SQLAlchemy is not installed")
|
||||||
|
self.db = sql.create_engine(self.config["appservice.database"],
|
||||||
|
**self.config["appservice.database_opts"])
|
||||||
|
Base.metadata.bind = self.db
|
||||||
|
if not self.db.has_table("alembic_version"):
|
||||||
|
self.log.critical("alembic_version table not found. "
|
||||||
|
"Did you forget to `alembic upgrade head`?")
|
||||||
|
sys.exit(10)
|
||||||
|
|
||||||
init_db(self.db)
|
init_db(self.db)
|
||||||
self.session_container = AlchemySessionContainer(
|
self.session_container = AlchemySessionContainer(
|
||||||
engine=self.db, table_base=Base, session=False,
|
engine=self.db, table_base=Base, session=False,
|
||||||
table_prefix="telethon_", manage_tables=False)
|
table_prefix="telethon_", manage_tables=False)
|
||||||
|
|
||||||
|
def make_state_store(self) -> None:
|
||||||
|
self.state_store = self.state_store_class(self.get_puppet, self.get_double_puppet)
|
||||||
|
|
||||||
def _prepare_website(self, context: Context) -> None:
|
def _prepare_website(self, context: Context) -> None:
|
||||||
if self.config["appservice.public.enabled"]:
|
if self.config["appservice.public.enabled"]:
|
||||||
public_website = PublicBridgeWebsite(self.loop)
|
public_website = PublicBridgeWebsite(self.loop)
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@ python-magic>=0.4,<0.5
|
|||||||
commonmark>=0.8,<0.10
|
commonmark>=0.8,<0.10
|
||||||
aiohttp>=3,<4
|
aiohttp>=3,<4
|
||||||
yarl>=1,<2
|
yarl>=1,<2
|
||||||
mautrix>=0.11.4,<0.13
|
mautrix>=0.13rc1,<0.14
|
||||||
telethon>=1.24,<1.25
|
telethon>=1.24,<1.25
|
||||||
telethon-session-sqlalchemy>=0.2.14,<0.3
|
telethon-session-sqlalchemy>=0.2.14,<0.3
|
||||||
# Temporarily always depend on aiosqlite to prevent breaking old installs
|
# Temporarily always depend on aiosqlite to prevent breaking old installs
|
||||||
|
|||||||
Reference in New Issue
Block a user