small refactoring

This commit is contained in:
vvzvlad
2025-04-15 02:43:26 +03:00
parent 10fc4f606c
commit 1871843b17
2 changed files with 6 additions and 6 deletions
+5 -5
View File
@@ -7,13 +7,13 @@
# type: ignore
import logging
import re
from datetime import datetime, timezone
from typing import Optional
from feedgen.feed import FeedGenerator
from pyrogram import errors
from post_parser import PostParser
from config import get_settings
import re
from pyrogram import errors
Config = get_settings()
@@ -276,8 +276,8 @@ async def generate_channel_rss(channel: str,
logger.warning(f"Could not get username for channel {channel}, using identifier for error feed.")
return create_error_feed(str(channel), base_url) # Ensure channel is string for error feed
except (errors.UsernameInvalid, errors.UsernameNotOccupied) as e:
logger.warning(f"Channel not found error for {channel}: {str(e)}")
return create_error_feed(channel, base_url)
logger.warning(f"Channel not found error for {channel}: {str(e)}")
return create_error_feed(channel, base_url)
except Exception as e:
logger.error(f"Error during get_chat for channel '{channel}' (type: {type(channel)}): {str(e)}", exc_info=True) # Log error specifically for get_chat
# Re-raise the original exception to be caught by the outer handler if needed,
@@ -439,4 +439,4 @@ def create_error_feed(channel: str, base_url: str) -> str:
rss_feed = fg.rss_str(pretty=True)
if isinstance(rss_feed, bytes):
return rss_feed.decode('utf-8')
return rss_feed
return rss_feed
+1 -1
View File
@@ -11,7 +11,7 @@ sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')
# Mock the config module before importing PostParser
sys.modules['config'] = __import__('tests.mock_config', fromlist=['get_settings'])
from pyrogram.types import Message, Chat, User, Reaction, MessageReactions
from pyrogram.types import Message, Chat, Reaction, MessageReactions
from pyrogram.enums import MessageMediaType
from post_parser import PostParser # Import after mocking config