Added skipping of user with invalid username
This commit is contained in:
parent
8dce3b1f62
commit
94302d09e9
|
@ -23,7 +23,8 @@ from telethon.errors.rpcerrorlist import (
|
|||
UsersTooMuchError,
|
||||
UserChannelsTooMuchError,
|
||||
UserIsBlockedError,
|
||||
YouBlockedUserError
|
||||
YouBlockedUserError,
|
||||
UsernameInvalidError,
|
||||
)
|
||||
|
||||
class PaperClient(TelegramClient):
|
||||
|
@ -93,11 +94,13 @@ class PaperClient(TelegramClient):
|
|||
return await super().get_participants(group, *args, **kwargs)
|
||||
|
||||
async def __cast_to_entity(self, entity: Entity | EntityLike) -> Entity:
|
||||
if not isinstance(entity, Entity):
|
||||
if hasattr(entity, "username"):
|
||||
entity = await self.get_entity(entity.username)
|
||||
else:
|
||||
entity = await self.get_entity(entity)
|
||||
|
||||
return entity # type: ignore
|
||||
try:
|
||||
if not isinstance(entity, Entity):
|
||||
if hasattr(entity, "username"):
|
||||
entity = await self.get_entity(entity.username)
|
||||
else:
|
||||
entity = await self.get_entity(entity)
|
||||
|
||||
return entity # type: ignore
|
||||
except UsernameInvalidError as e:
|
||||
raise IgnoreException(e)
|
||||
|
|
Loading…
Reference in New Issue