Skip to content

Commit

Permalink
Fix some things
Browse files Browse the repository at this point in the history
  • Loading branch information
tulir committed Oct 22, 2019
1 parent bf4c062 commit 0a7f80d
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 3 deletions.
8 changes: 5 additions & 3 deletions maubot/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
EventType, Filter, RoomFilter, RoomEventFilter)
from mautrix.client import InternalEventType

from .lib.store_proxy import ClientStoreProxy
from .db import DBClient
from .matrix import MaubotMatrixClient

Expand Down Expand Up @@ -58,7 +59,8 @@ def __init__(self, db_instance: DBClient) -> None:
self.remote_avatar_url = None
self.client = MaubotMatrixClient(mxid=self.id, base_url=self.homeserver,
token=self.access_token, client_session=self.http_client,
log=self.log, loop=self.loop, store=self.db_instance)
log=self.log, loop=self.loop,
store=ClientStoreProxy(self.db_instance))
self.client.ignore_initial_sync = True
self.client.ignore_first_sync = True
if self.autojoin:
Expand Down Expand Up @@ -107,13 +109,13 @@ async def _start(self, try_n: Optional[int] = 0) -> None:
self.db_instance.enabled = False
return
if not self.filter_id:
self.db_instance.filter_id = await self.client.create_filter(Filter(
self.db_instance.edit(filter_id=await self.client.create_filter(Filter(
room=RoomFilter(
timeline=RoomEventFilter(
limit=50,
),
),
))
)))
if self.displayname != "disable":
await self.client.set_displayname(self.displayname)
if self.avatar_url != "disable":
Expand Down
30 changes: 30 additions & 0 deletions maubot/lib/store_proxy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# maubot - A plugin-based Matrix bot system.
# Copyright (C) 2019 Tulir Asokan
#
# 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 mautrix.client import ClientStore
from mautrix.types import SyncToken


class ClientStoreProxy(ClientStore):
def __init__(self, db_instance) -> None:
self.db_instance = db_instance

@property
def next_batch(self) -> SyncToken:
return self.db_instance.next_batch

@next_batch.setter
def next_batch(self, value: SyncToken) -> None:
self.db_instance.edit(next_batch=value)
1 change: 1 addition & 0 deletions maubot/loader/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class PluginMeta(SerializableAttrs['PluginMeta']):

maubot: Version = Version(__version__)
database: bool = False
config: bool = False
webapp: bool = False
license: str = ""
extra_files: List[str] = []
Expand Down
1 change: 1 addition & 0 deletions maubot/management/api/responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from aiohttp import web
from sqlalchemy.exc import OperationalError, IntegrityError


class _Response:
@property
def body_not_json(self) -> web.Response:
Expand Down

0 comments on commit 0a7f80d

Please sign in to comment.