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