Skip to content

Commit

Permalink
more try
Browse files Browse the repository at this point in the history
  • Loading branch information
MeetWq committed Jun 25, 2023
1 parent 4ae18ba commit 61b1c1a
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions nonebot_plugin_userinfo/adapters/telegram.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,22 @@ async def _get_info(self, user_id: str) -> Optional[UserInfo]:

if user:
avatar = None
profile_photos = await self.bot.get_user_profile_photos(
user_id=user.id, limit=1
)
try:
profile_photos = await self.bot.get_user_profile_photos(
user_id=user.id, limit=1
)
except ActionFailed as e:
logger.warning(f"Error calling get_user_profile_photos: {e}")
profile_photos = None

if profile_photos and profile_photos.total_count > 0:
file_id = profile_photos.photos[0][-1].file_id
file = await self.bot.get_file(file_id=file_id)
try:
file = await self.bot.get_file(file_id=file_id)
except ActionFailed as e:
logger.warning(f"Error calling get_file: {e}")
file = None

if file and file.file_path:
config = self.bot.bot_config
avatar = TelegramFile(
Expand Down

0 comments on commit 61b1c1a

Please sign in to comment.