Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| cb9665f9ab | |||
| 69ffdcfed6 | |||
| da72c51644 | |||
| 62efc39eed | |||
| 07edcc4867 | |||
| 65d7934c21 | |||
| 842d98dc1c | |||
| b7e69ddc61 | |||
| 82f7905367 | |||
| 1d8699054c | |||
| 32c521cb79 | |||
| b4cf8cd451 | |||
| 80ff9d0f66 | |||
| b0e60e60e4 | |||
| c4b9a76931 | |||
| fe52f0ad10 |
+4
-3
@@ -6,9 +6,9 @@
|
|||||||
* [x] Message edits
|
* [x] Message edits
|
||||||
* [ ] ‡ Message history
|
* [ ] ‡ Message history
|
||||||
* [x] Presence
|
* [x] Presence
|
||||||
* [x] Typing notifications
|
* [x] Typing notifications*
|
||||||
* [x] Read receipts
|
* [x] Read receipts*
|
||||||
* [x] Pinning messages
|
* [x] Pinning messages*
|
||||||
* [x] Power level
|
* [x] Power level
|
||||||
* [x] Normal chats
|
* [x] Normal chats
|
||||||
* [ ] Non-hardcoded PL requirements
|
* [ ] Non-hardcoded PL requirements
|
||||||
@@ -56,5 +56,6 @@
|
|||||||
* [ ] ‡ Secret chats (not yet supported by Telethon)
|
* [ ] ‡ Secret chats (not yet supported by Telethon)
|
||||||
* [ ] ‡ E2EE in Matrix rooms (not yet supported
|
* [ ] ‡ E2EE in Matrix rooms (not yet supported
|
||||||
|
|
||||||
|
\* Requires [double puppeting](https://github.com/tulir/mautrix-telegram/wiki/Authentication#replacing-telegram-accounts-matrix-puppet-with-matrix-account) to be enabled
|
||||||
† Information not automatically sent from source, i.e. implementation may not be possible
|
† Information not automatically sent from source, i.e. implementation may not be possible
|
||||||
‡ Maybe, i.e. this feature may or may not be implemented at some point
|
‡ Maybe, i.e. this feature may or may not be implemented at some point
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
__version__ = "0.7.0"
|
__version__ = "0.7.2"
|
||||||
__author__ = "Tulir Asokan <tulir@maunium.net>"
|
__author__ = "Tulir Asokan <tulir@maunium.net>"
|
||||||
|
|||||||
@@ -97,7 +97,6 @@ class AbstractUser(ABC):
|
|||||||
self.client = None
|
self.client = None
|
||||||
self.is_relaybot = False
|
self.is_relaybot = False
|
||||||
self.is_bot = False
|
self.is_bot = False
|
||||||
self.relaybot = None
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def connected(self) -> bool:
|
def connected(self) -> bool:
|
||||||
@@ -422,8 +421,9 @@ class AbstractUser(ABC):
|
|||||||
f" in unbridged chat {portal.tgid_log}")
|
f" in unbridged chat {portal.tgid_log}")
|
||||||
return
|
return
|
||||||
|
|
||||||
if self.ignore_incoming_bot_events and self.relaybot and sender.id == self.relaybot.tgid:
|
if ((self.ignore_incoming_bot_events and self.relaybot
|
||||||
self.log.debug(f"Ignoring relaybot-sent message %s to %s", update, portal.tgid_log)
|
and sender and sender.id == self.relaybot.tgid)):
|
||||||
|
self.log.debug(f"Ignoring relaybot-sent message %s to %s", update.id, portal.tgid_log)
|
||||||
return
|
return
|
||||||
|
|
||||||
if isinstance(update, MessageService):
|
if isinstance(update, MessageService):
|
||||||
|
|||||||
@@ -108,9 +108,9 @@ class Bot(AbstractUser):
|
|||||||
if isinstance(chat, ChatForbidden) or chat.left or chat.deactivated:
|
if isinstance(chat, ChatForbidden) or chat.left or chat.deactivated:
|
||||||
self.remove_chat(TelegramID(chat.id))
|
self.remove_chat(TelegramID(chat.id))
|
||||||
|
|
||||||
channel_ids = (InputChannel(chat_id, 0)
|
channel_ids = [InputChannel(chat_id, 0)
|
||||||
for chat_id, chat_type in self.chats.items()
|
for chat_id, chat_type in self.chats.items()
|
||||||
if chat_type == "channel")
|
if chat_type == "channel"]
|
||||||
for channel_id in channel_ids:
|
for channel_id in channel_ids:
|
||||||
try:
|
try:
|
||||||
await self.client(GetChannelsRequest([channel_id]))
|
await self.client(GetChannelsRequest([channel_id]))
|
||||||
|
|||||||
@@ -222,7 +222,7 @@ class BasePortal(ABC):
|
|||||||
return False
|
return False
|
||||||
evt_type = EventType.find(f"net.maunium.telegram.{event}")
|
evt_type = EventType.find(f"net.maunium.telegram.{event}")
|
||||||
evt_type.t_class = EventType.Class.STATE
|
evt_type.t_class = EventType.Class.STATE
|
||||||
return self.main_intent.state_store.has_power_level(self.mxid, user.mxid, event=evt_type)
|
return self.main_intent.state_store.has_power_level(self.mxid, user.mxid, evt_type)
|
||||||
|
|
||||||
def get_input_entity(self, user: 'AbstractUser'
|
def get_input_entity(self, user: 'AbstractUser'
|
||||||
) -> Awaitable[Union[TypeInputPeer, TypeInputChannel]]:
|
) -> Awaitable[Union[TypeInputPeer, TypeInputChannel]]:
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ from telethon.tl.types import (UserProfilePhoto, User, UpdateUserName, PeerUser,
|
|||||||
from mautrix.appservice import AppService, IntentAPI
|
from mautrix.appservice import AppService, IntentAPI
|
||||||
from mautrix.errors import MatrixRequestError
|
from mautrix.errors import MatrixRequestError
|
||||||
from mautrix.bridge import CustomPuppetMixin
|
from mautrix.bridge import CustomPuppetMixin
|
||||||
from mautrix.types import UserID, SyncToken
|
from mautrix.types import UserID, SyncToken, RoomID
|
||||||
from mautrix.util.simple_template import SimpleTemplate
|
from mautrix.util.simple_template import SimpleTemplate
|
||||||
|
|
||||||
from .types import TelegramID
|
from .types import TelegramID
|
||||||
@@ -320,6 +320,10 @@ class Puppet(CustomPuppetMixin):
|
|||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def default_puppet_should_leave_room(self, room_id: RoomID) -> bool:
|
||||||
|
portal: p.Portal = p.Portal.get_by_mxid(room_id)
|
||||||
|
return portal and not portal.backfilling and portal.peer_type != "user"
|
||||||
|
|
||||||
# endregion
|
# endregion
|
||||||
# region Getters
|
# region Getters
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,8 @@ def log(message, end="\n"):
|
|||||||
|
|
||||||
|
|
||||||
def connect(to):
|
def connect(to):
|
||||||
from mautrix.bridge.db import Base, RoomState, UserProfile
|
from mautrix.util.db import Base
|
||||||
|
from mautrix.bridge.db import RoomState, UserProfile
|
||||||
from mautrix_telegram.db import (Portal, Message, UserPortal, User, Contact, Puppet, BotChat,
|
from mautrix_telegram.db import (Portal, Message, UserPortal, User, Contact, Puppet, BotChat,
|
||||||
TelegramFile)
|
TelegramFile)
|
||||||
|
|
||||||
|
|||||||
@@ -355,6 +355,7 @@ class ProvisioningAPI(AuthAPI):
|
|||||||
if err is not None:
|
if err is not None:
|
||||||
return err
|
return err
|
||||||
await user.log_out()
|
await user.log_out()
|
||||||
|
return web.json_response({}, status=200)
|
||||||
|
|
||||||
async def bridge_info(self, request: web.Request) -> web.Response:
|
async def bridge_info(self, request: web.Request) -> web.Response:
|
||||||
return web.json_response({
|
return web.json_response({
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ def context(request: FixtureRequest) -> Context:
|
|||||||
"""
|
"""
|
||||||
# Config(path, registration_path, base_path)
|
# Config(path, registration_path, base_path)
|
||||||
config = getattr(request.cls, 'config', Config("", "", ""))
|
config = getattr(request.cls, 'config', Config("", "", ""))
|
||||||
return Context(az=Mock(), config=config, loop=Mock(), session_container=Mock(), bot=Mock())
|
return Context(az=Mock(), config=config, loop=Mock(), session_container=Mock(), bridge=Mock(), bot=Mock())
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
@@ -52,6 +52,7 @@ class TestCommandEvent:
|
|||||||
sender=u.User(UserID("@sender:example.org")),
|
sender=u.User(UserID("@sender:example.org")),
|
||||||
command="help",
|
command="help",
|
||||||
args=[],
|
args=[],
|
||||||
|
content=Mock(),
|
||||||
is_management=True,
|
is_management=True,
|
||||||
is_portal=False,
|
is_portal=False,
|
||||||
)
|
)
|
||||||
@@ -107,6 +108,7 @@ class TestCommandEvent:
|
|||||||
sender=u.User(UserID("@sender:example.org")),
|
sender=u.User(UserID("@sender:example.org")),
|
||||||
command="help",
|
command="help",
|
||||||
args=[],
|
args=[],
|
||||||
|
content=Mock(),
|
||||||
is_management=False,
|
is_management=False,
|
||||||
is_portal=False,
|
is_portal=False,
|
||||||
)
|
)
|
||||||
@@ -133,6 +135,7 @@ class TestCommandEvent:
|
|||||||
sender=u.User(UserID("@sender:example.org")),
|
sender=u.User(UserID("@sender:example.org")),
|
||||||
command="help",
|
command="help",
|
||||||
args=[],
|
args=[],
|
||||||
|
content=Mock(),
|
||||||
is_management=True,
|
is_management=True,
|
||||||
is_portal=False,
|
is_portal=False,
|
||||||
)
|
)
|
||||||
@@ -209,6 +212,7 @@ class TestCommandHandler:
|
|||||||
sender=sender,
|
sender=sender,
|
||||||
command=command,
|
command=command,
|
||||||
args=[],
|
args=[],
|
||||||
|
content=Mock(),
|
||||||
is_management=False,
|
is_management=False,
|
||||||
is_portal=boolean,
|
is_portal=boolean,
|
||||||
)
|
)
|
||||||
@@ -271,6 +275,7 @@ class TestCommandHandler:
|
|||||||
sender=sender,
|
sender=sender,
|
||||||
command=command,
|
command=command,
|
||||||
args=[],
|
args=[],
|
||||||
|
content=Mock(),
|
||||||
is_management=is_management,
|
is_management=is_management,
|
||||||
is_portal=boolean,
|
is_portal=boolean,
|
||||||
)
|
)
|
||||||
@@ -307,6 +312,7 @@ class TestCommandProcessor:
|
|||||||
sender=sender,
|
sender=sender,
|
||||||
command="hElp",
|
command="hElp",
|
||||||
args=[],
|
args=[],
|
||||||
|
content=Mock(),
|
||||||
is_management=boolean2[0],
|
is_management=boolean2[0],
|
||||||
is_portal=boolean2[1])
|
is_portal=boolean2[1])
|
||||||
|
|
||||||
@@ -333,6 +339,7 @@ class TestCommandProcessor:
|
|||||||
sender=sender,
|
sender=sender,
|
||||||
command="foo",
|
command="foo",
|
||||||
args=[],
|
args=[],
|
||||||
|
content=Mock(),
|
||||||
is_management=boolean2[0],
|
is_management=boolean2[0],
|
||||||
is_portal=boolean2[1],
|
is_portal=boolean2[1],
|
||||||
)
|
)
|
||||||
@@ -361,6 +368,7 @@ class TestCommandProcessor:
|
|||||||
sender=sender, # u.User
|
sender=sender, # u.User
|
||||||
command="foo",
|
command="foo",
|
||||||
args=[],
|
args=[],
|
||||||
|
content=Mock(),
|
||||||
is_management=boolean2[0],
|
is_management=boolean2[0],
|
||||||
is_portal=boolean2[1]
|
is_portal=boolean2[1]
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user