Skip to content

Commit

Permalink
Wrap message sending in try..catch block (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
jckling authored Aug 26, 2023
1 parent d1ec5ed commit 645da36
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 35 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ Telegram 推送结果

## 说明

使用方式同 [jckling/Daily-Bonus](https://github.com/jckling/Daily-Bonus),star 一下,再 fork 本仓库设置 Secrets 就可以运行了,自定义推送时间修改 .github/workflows/ 目录下对应的配置文件即可。
**支持本仓库请 star**

使用方式同 [jckling/Daily-Bonus](https://github.com/jckling/Daily-Bonus),fork 本仓库然后设置 Actions Secrets 就可以运行了。自定义推送时间修改 .github/workflows/ 目录下对应的配置文件即可,时间格式参考 [events-that-trigger-workflows#schedule](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#schedule)


| Secret 名称 | 描述 |
| --------------------- | --------------------- |
Expand Down
71 changes: 37 additions & 34 deletions cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,40 +21,43 @@


async def main():
if args.daily:
# Bing 壁纸
image, info = explore_wallpaper()
await bot.sendPhoto(
chat_id=CHAT_ID,
photo=image,
caption=info
)

if args.weekly:
# Pixiv 插画周榜
lst = weekly_ranking()
await bot.sendMediaGroup(
chat_id=CHAT_ID,
media=lst
)

if args.daily_night:
# Yamibo 中文漫画更新
msg = yuri_manga()
await bot.sendMessage(
chat_id=CHAT_ID,
text=msg,
parse_mode="HTML"
)

# Bilibili 动态更新
msg = ups_updates()
await bot.sendMessage(
chat_id=CHAT_ID,
text=msg,
parse_mode="HTML",
disable_web_page_preview=True
)
try:
if args.daily:
# Bing 壁纸
image, info = explore_wallpaper()
await bot.sendPhoto(
chat_id=CHAT_ID,
photo=image,
caption=info
)

if args.weekly:
# Pixiv 插画周榜
lst = weekly_ranking()
await bot.sendMediaGroup(
chat_id=CHAT_ID,
media=lst
)

if args.daily_night:
# Yamibo 中文漫画更新
msg = yuri_manga()
await bot.sendMessage(
chat_id=CHAT_ID,
text=msg,
parse_mode="HTML"
)

# Bilibili 动态更新
msg = ups_updates()
await bot.sendMessage(
chat_id=CHAT_ID,
text=msg,
parse_mode="HTML",
disable_web_page_preview=True
)
except Exception as e:
print("Error: %s" % e)


asyncio.run(main())

0 comments on commit 645da36

Please sign in to comment.