Add some missing awaits
This commit is contained in:
@@ -83,7 +83,7 @@ class MatrixHandler:
|
|||||||
await puppet.intent.send_notice(room, "Portal to private chat created.")
|
await puppet.intent.send_notice(room, "Portal to private chat created.")
|
||||||
else:
|
else:
|
||||||
await puppet.intent.join_room(room)
|
await puppet.intent.join_room(room)
|
||||||
await puppet.intent.send_notice(room, "This puppet will remain inactive until a"
|
await puppet.intent.send_notice(room, "This puppet will remain inactive until a "
|
||||||
"Telegram chat is created for this room.")
|
"Telegram chat is created for this room.")
|
||||||
|
|
||||||
async def handle_invite(self, room, user, inviter):
|
async def handle_invite(self, room, user, inviter):
|
||||||
|
|||||||
@@ -367,7 +367,7 @@ class Portal:
|
|||||||
del self.by_tgid[self.tgid_full]
|
del self.by_tgid[self.tgid_full]
|
||||||
del self.by_mxid[self.mxid]
|
del self.by_mxid[self.mxid]
|
||||||
elif source and source.tgid != user.tgid:
|
elif source and source.tgid != user.tgid:
|
||||||
target = user.get_input_entity(source)
|
target = await user.get_input_entity(source)
|
||||||
if self.peer_type == "chat":
|
if self.peer_type == "chat":
|
||||||
await source.client(DeleteChatUserRequest(chat_id=self.tgid, user_id=target))
|
await source.client(DeleteChatUserRequest(chat_id=self.tgid, user_id=target))
|
||||||
else:
|
else:
|
||||||
@@ -456,8 +456,9 @@ class Portal:
|
|||||||
invite_link=moderator, pin_messages=moderator,
|
invite_link=moderator, pin_messages=moderator,
|
||||||
add_admins=admin, manage_call=moderator)
|
add_admins=admin, manage_call=moderator)
|
||||||
await sender.client(
|
await sender.client(
|
||||||
EditAdminRequest(channel=self.get_input_entity(sender),
|
EditAdminRequest(channel=await self.get_input_entity(sender),
|
||||||
user_id=sender.client.get_input_entity(PeerUser(user_id)),
|
user_id=await sender.client.get_input_entity(
|
||||||
|
PeerUser(user_id)),
|
||||||
admin_rights=rights))
|
admin_rights=rights))
|
||||||
|
|
||||||
async def handle_matrix_about(self, sender, about):
|
async def handle_matrix_about(self, sender, about):
|
||||||
@@ -543,7 +544,7 @@ class Portal:
|
|||||||
if self.peer_type != "channel":
|
if self.peer_type != "channel":
|
||||||
raise ValueError("Only channels and supergroups have usernames.")
|
raise ValueError("Only channels and supergroups have usernames.")
|
||||||
await source.client(
|
await source.client(
|
||||||
UpdateUsernameRequest(self.get_input_entity(source), username))
|
UpdateUsernameRequest(await self.get_input_entity(source), username))
|
||||||
if await self.update_username(username):
|
if await self.update_username(username):
|
||||||
self.save()
|
self.save()
|
||||||
|
|
||||||
@@ -569,7 +570,7 @@ class Portal:
|
|||||||
megagroup=supergroup))
|
megagroup=supergroup))
|
||||||
entity = updates.chats[0]
|
entity = updates.chats[0]
|
||||||
await source.client(InviteToChannelRequest(
|
await source.client(InviteToChannelRequest(
|
||||||
channel=source.client.get_input_entity(entity),
|
channel=await source.client.get_input_entity(entity),
|
||||||
users=invites))
|
users=invites))
|
||||||
else:
|
else:
|
||||||
raise ValueError("Invalid peer type for Telegram chat creation")
|
raise ValueError("Invalid peer type for Telegram chat creation")
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ class User:
|
|||||||
if changed:
|
if changed:
|
||||||
self.save()
|
self.save()
|
||||||
|
|
||||||
def log_out(self):
|
async def log_out(self):
|
||||||
self.connected = False
|
self.connected = False
|
||||||
if self.tgid:
|
if self.tgid:
|
||||||
try:
|
try:
|
||||||
@@ -136,7 +136,8 @@ class User:
|
|||||||
pass
|
pass
|
||||||
self.tgid = None
|
self.tgid = None
|
||||||
self.save()
|
self.save()
|
||||||
return self.client.log_out()
|
await self.client.log_out()
|
||||||
|
# TODO kick user from portals
|
||||||
|
|
||||||
async def sync_dialogs(self):
|
async def sync_dialogs(self):
|
||||||
dialogs = await self.client.get_dialogs(limit=30)
|
dialogs = await self.client.get_dialogs(limit=30)
|
||||||
|
|||||||
Reference in New Issue
Block a user