Update Telethon
This commit is contained in:
@@ -57,6 +57,7 @@ from telethon.tl.types import (
|
||||
UpdateReadChannelInbox,
|
||||
UpdateReadHistoryInbox,
|
||||
UpdateReadHistoryOutbox,
|
||||
UpdateShort,
|
||||
UpdateShortChatMessage,
|
||||
UpdateShortMessage,
|
||||
UpdateUserName,
|
||||
@@ -297,6 +298,8 @@ class AbstractUser(ABC):
|
||||
# region Telegram update handling
|
||||
|
||||
async def _update(self, update: TypeUpdate) -> None:
|
||||
if isinstance(update, UpdateShort):
|
||||
update = update.update
|
||||
asyncio.create_task(self._handle_entity_updates(getattr(update, "_entities", {})))
|
||||
if isinstance(
|
||||
update,
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, ClassVar
|
||||
from typing import TYPE_CHECKING, ClassVar, Iterable
|
||||
import asyncio
|
||||
import datetime
|
||||
|
||||
@@ -124,19 +124,19 @@ class PgSession(MemorySession):
|
||||
return updates.State(row["pts"], row["qts"], date, row["seq"], row["unread_count"])
|
||||
|
||||
async def set_update_state(self, entity_id: int, row: updates.State) -> None:
|
||||
q = (
|
||||
"INSERT INTO telethon_update_state"
|
||||
" (session_id, entity_id, pts, qts, date, seq, unread_count) "
|
||||
"VALUES ($1, $2, $3, $4, $5, $6, $7)"
|
||||
"ON CONFLICT (session_id, entity_id) DO UPDATE"
|
||||
" SET pts=$3, qts=$4, date=$5, seq=$6, unread_count=$7"
|
||||
)
|
||||
q = """
|
||||
INSERT INTO telethon_update_state(session_id, entity_id, pts, qts, date, seq, unread_count)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7)
|
||||
ON CONFLICT (session_id, entity_id) DO UPDATE SET
|
||||
pts=excluded.pts, qts=excluded.qts, date=excluded.date, seq=excluded.seq,
|
||||
unread_count=excluded.unread_count
|
||||
"""
|
||||
ts = row.date.timestamp()
|
||||
await self.db.execute(
|
||||
q, self.session_id, entity_id, row.pts, row.qts, ts, row.seq, row.unread_count
|
||||
)
|
||||
|
||||
async def get_update_states(self) -> tuple[tuple[int, updates.State], ...]:
|
||||
async def get_update_states(self) -> Iterable[tuple[int, updates.State], ...]:
|
||||
q = (
|
||||
"SELECT entity_id, pts, qts, date, seq, unread_count FROM telethon_update_state "
|
||||
"WHERE session_id=$1"
|
||||
|
||||
+1
-2
@@ -5,8 +5,7 @@ aiohttp>=3,<4
|
||||
yarl>=1,<2
|
||||
mautrix>=0.16.4,<0.17
|
||||
#telethon>=1.24,<1.25
|
||||
# Fork to make session storage async and update to layer 138
|
||||
tulir-telethon==1.25.0a7
|
||||
tulir-telethon==1.25.0a8
|
||||
asyncpg>=0.20,<0.26
|
||||
mako>=1,<2
|
||||
setuptools
|
||||
|
||||
Reference in New Issue
Block a user