fix(userbot): add missing safone.py imports, apply ruff --unsafe-fixes
- Add missing aiohttp, PIL, BytesIO imports to safone.py (F821 runtime bugs) - Apply ruff --unsafe-fixes (27 fixes): ternary operators, .get() patterns, contextlib.suppress, enumerate(), collapsible if/else, remove .keys()
This commit is contained in:
@@ -25,7 +25,7 @@ def get_marine_life_details(species_name):
|
||||
species = observation['taxon']['name']
|
||||
common_name = observation['taxon']['preferred_common_name']
|
||||
photo_url = observation['photos'][0]['url'] if observation['photos'] else 'No photo available'
|
||||
description = observation['description'] if 'description' in observation else 'No description available.'
|
||||
description = observation.get('description', 'No description available.')
|
||||
return {
|
||||
'species': species,
|
||||
'common_name': common_name,
|
||||
|
||||
@@ -16,9 +16,12 @@
|
||||
|
||||
import base64
|
||||
import os
|
||||
from io import BytesIO
|
||||
|
||||
import aiofiles
|
||||
import aiohttp
|
||||
import requests
|
||||
from PIL import Image, ImageEnhance
|
||||
from pyrogram import Client, enums, filters
|
||||
from pyrogram.errors import MediaCaptionTooLong, MessageTooLong
|
||||
from pyrogram.types import InputMediaPhoto, Message
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
import asyncio
|
||||
import contextlib
|
||||
import os
|
||||
|
||||
import requests
|
||||
@@ -101,10 +102,8 @@ async def delete_search_data(client, chat_id, message_id):
|
||||
search_key = f'{chat_id}_{key}'
|
||||
if search_key in search_results and search_results[search_key]['message_id'] == message_id:
|
||||
del search_results[search_key]
|
||||
try:
|
||||
with contextlib.suppress(BaseException):
|
||||
await client.delete_messages(chat_id, message_id)
|
||||
except:
|
||||
pass
|
||||
break
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user