Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
aturret committed Oct 24, 2024
1 parent caf9b84 commit 8e01a91
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
5 changes: 4 additions & 1 deletion app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
TELEGRAM_BOT_SECRET_TOKEN = env.get(
"TELEGRAM_BOT_SECRET_TOKEN", secrets.token_urlsafe(32)
)

TELEGRAM_CHANNEL_ID = []
telegram_channel_id = env.get("TELEGRAM_CHANNEL_ID", "").split(",")
for single_telegram_channel_id in telegram_channel_id:
Expand All @@ -60,7 +61,9 @@
]
if not TELEGRAM_CHANNEL_ADMIN_LIST:
TELEGRAM_CHANNEL_ADMIN_LIST = None

TELEGRAM_WEBHOOK_URL = f"https://{BASE_URL}/telegram/bot/webhook"

TELEBOT_API_SERVER_HOST = env.get("TELEBOT_API_SERVER_HOST", None)
TELEBOT_API_SERVER_PORT = env.get("TELEBOT_API_SERVER_PORT", None)
TELEBOT_API_SERVER = (
Expand Down Expand Up @@ -206,4 +209,4 @@ def ban_list_resolver(ban_list_string: str) -> list:
_ = translation.gettext

# Utils environment variables
HTTP_REQUEST_TIMEOUT = env.get("HTTP_REQUEST_TIMEOUT", 30)
HTTP_REQUEST_TIMEOUT = env.get("HTTP_REQUEST_TIMEOUT", 30)
1 change: 0 additions & 1 deletion app/models/database_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,3 @@ def from_dict(obj: Any) -> "Metadata":

document_list = [Metadata]
document_list.extend(telegram_chat_document_list)
logger.debug(f"document_list: {document_list}")
6 changes: 3 additions & 3 deletions app/models/metadata_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class MetadataItem:
title: str
author_url: str
category: str
message_type: str
message_type: MessageType

@staticmethod
def from_dict(obj: Any) -> "MetadataItem":
Expand All @@ -82,7 +82,7 @@ def from_dict(obj: Any) -> "MetadataItem":
title = from_str(obj.get("title"))
author_url = from_str(obj.get("author_url"))
category = from_str(obj.get("category"))
message_type = from_str(obj.get("message_type"))
message_type = MessageType(obj.get("message_type"))
return MetadataItem(
url,
telegraph_url,
Expand All @@ -109,7 +109,7 @@ def to_dict(self) -> dict:
result["title"] = from_str(self.title)
result["author_url"] = from_str(self.author_url)
result["category"] = from_str(self.category)
result["message_type"] = from_str(self.message_type)
result["message_type"] = self.message_type.value
return result


Expand Down
6 changes: 6 additions & 0 deletions app/utils/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ def second_to_time(second: int) -> str:
return "{:02d}:{:02d}:{:02d}".format(h, m, s)


def string_to_list(string: str, divider: str = ",") -> list:
if string is None:
return []
return string.split(divider)


async def get_url_metadata(url: str, ban_list: Optional[list] = None) -> UrlMetadata:
if not ban_list:
ban_list = []
Expand Down

0 comments on commit 8e01a91

Please sign in to comment.