Implement Matrix->Telegram typing notifications

This commit is contained in:
Tulir Asokan
2018-07-21 11:19:19 -04:00
parent 54287c344f
commit 54d7ac5542
3 changed files with 53 additions and 9 deletions
+5
View File
@@ -22,6 +22,7 @@ import re
from telethon.tl.types import *
from telethon.tl.types.contacts import ContactsNotModified
from telethon.tl.functions.contacts import GetContactsRequest, SearchRequest
from telethon.tl.functions.messages import SetTypingRequest
from mautrix_appservice import MatrixRequestError
from .db import User as DBUser, Contact as DBContact
@@ -203,6 +204,10 @@ class User(AbstractUser):
if changed:
self.save()
def set_typing(self, peer, typing=True, action=SendMessageTypingAction):
return self.client(
SetTypingRequest(peer, action() if typing else SendMessageCancelAction()))
async def log_out(self):
for _, portal in self.portals.items():
if portal.has_bot: