Fix some issues with auto-creating groups
This commit is contained in:
@@ -312,8 +312,8 @@ bridge:
|
||||
kick_on_logout: true
|
||||
# Should the "* user joined Telegram" notice always be marked as read automatically?
|
||||
always_read_joined_telegram_notice: true
|
||||
# auto-create group chat portals by inviting Matrix puppet of Telegram user to a room
|
||||
# requires double-puppeting to be enabled
|
||||
# Should the bridge auto-create a group chat on Telegram when a ghost is invited to a room?
|
||||
# Requires the user to have sufficient power level and double puppeting enabled.
|
||||
create_group_on_invite: true
|
||||
# Settings for backfilling messages from Telegram.
|
||||
backfill:
|
||||
|
||||
@@ -75,7 +75,7 @@ class MatrixHandler(BaseMatrixHandler):
|
||||
if (
|
||||
not double_puppet
|
||||
or self.az.bot_mxid in members
|
||||
or not not self.config["bridge.create_group_on_invite"]
|
||||
or not self.config["bridge.create_group_on_invite"]
|
||||
):
|
||||
if self.az.bot_mxid not in members:
|
||||
await puppet.default_mxid_intent.leave_room(
|
||||
@@ -85,7 +85,8 @@ class MatrixHandler(BaseMatrixHandler):
|
||||
else:
|
||||
await puppet.default_mxid_intent.send_notice(
|
||||
room_id,
|
||||
"This ghost will remain inactive until a Telegram chat is created for this room.",
|
||||
"This ghost will remain inactive "
|
||||
"until a Telegram chat is created for this room.",
|
||||
)
|
||||
return
|
||||
elif not await user_has_power_level(
|
||||
@@ -101,7 +102,7 @@ class MatrixHandler(BaseMatrixHandler):
|
||||
title, about, levels, encrypted = await get_initial_state(double_puppet.intent, room_id)
|
||||
if not title:
|
||||
await puppet.default_mxid_intent.leave_room(
|
||||
room_id, reason="Please set a title before inviting Telegram puppets."
|
||||
room_id, reason="Please set a title before inviting Telegram ghosts."
|
||||
)
|
||||
return
|
||||
|
||||
@@ -137,7 +138,8 @@ class MatrixHandler(BaseMatrixHandler):
|
||||
await portal.create_telegram_chat(invited_by, invites=invites, supergroup=True)
|
||||
except ValueError as e:
|
||||
await portal.delete()
|
||||
return await portal.az.intent.send_notice(room_id, e.args[0])
|
||||
await portal.az.intent.send_notice(room_id, e.args[0])
|
||||
return
|
||||
|
||||
async def handle_invite(
|
||||
self, room_id: RoomID, user_id: UserID, inviter: u.User, event_id: EventID
|
||||
|
||||
@@ -438,7 +438,7 @@ class Portal(DBPortal, BasePortal):
|
||||
|
||||
async def get_telegram_users_in_matrix_room(
|
||||
self, source: u.User, pre_create: bool = False
|
||||
) -> tuple[list[InputPeerUser], list[UserID]]:
|
||||
) -> tuple[list[InputUser], list[UserID]]:
|
||||
user_tgids = {}
|
||||
intent = self.az.intent if pre_create else self.main_intent
|
||||
user_mxids = await intent.get_room_members(self.mxid, (Membership.JOIN, Membership.INVITE))
|
||||
|
||||
Reference in New Issue
Block a user