Skip to content

Commit

Permalink
fix: limit telegram message length
Browse files Browse the repository at this point in the history
  • Loading branch information
z0z0r4 committed Dec 29, 2024
1 parent 695d1ed commit b247183
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions utils/telegram/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ def __init__(self, platform: str, projects_detail_info: List[ProjectDetail]):
def send_to_telegram(self):
message = f"本次从 API 请求中总共捕捉到 {self.catched_count}{self.platform} 模组数据:"
for project in self.projects_detail_info:
if len(message) > 4000: # Telegram 限制消息长度 4096 字符
break
message += f"\n{project.name} (ID: {project.id}) 共有 {project.version_count} 个版本"

send_message_sync(message)
send_message_sync(message)

0 comments on commit b247183

Please sign in to comment.