📤
简介
通过 Telegram Bot API 发送图片的 Python 脚本,支持本地图像文件上传与可选文字说明,适合自动化通知场景。
原始描述
Send photos via Telegram Bot API.
通过你的 Agent 添加
安装目录:telegram-send-photo/(目录名取自 SKILL.md 的 frontmatter name,不是 URL 里的 slug)。
点「快速安装」复制一段指令贴给你的 Agent:它会先下载到 /tmp、把文件清单和校验值给你看,你确认之后才解压安装。不会一步装完、也不改系统其它位置。
或者手动安装
Claude Code~/.claude/skills/telegram-send-photo/
Codex CLI~/.codex/skills/telegram-send-photo/
DeepSeek Harness~/.agents/skills/telegram-send-photo/
包是「根级 SKILL.md + 作者附带的文件」,解压到上面的 <slug>/ 目录即可;
目录名不用换,也不要把包直接解压到 skills 根目录。
技能申请的权限由作者决定:装之前先看清单里有没有脚本、它会读写什么。
技能正文
name: telegram-send-photo
description: Send photos via Telegram Bot API.
Description
This skill allows sending image files to Telegram using the Bot API. Useful for sharing screenshots, images, or any visual content through Telegram.
Requirements
- Python 3.x
- requests library (
pip install requests)
- Telegram Bot Token
- Target Chat ID
Usage
Python Script
import requests
# Configuration
bot_token = "YOUR_BOT_TOKEN"
chat_id = "YOUR_CHAT_ID"
photo_path = "path/to/image.png"
# Send photo
url = f"https://api.telegram.org/bot{bot_token}/sendPhoto"
files = {"photo": open(photo_path, "rb")}
data = {"chat_id": chat_id, "caption": "图片描述"}
resp = requests.post(url, files=files, data=data)
# Check response
if resp.status_code == 200:
print("Photo sent successfully!")
else:
print(f"Failed: {resp.text}")
Key Points
pip install requests)Python Script
import requests
# Configuration
bot_token = "YOUR_BOT_TOKEN"
chat_id = "YOUR_CHAT_ID"
photo_path = "path/to/image.png"
# Send photo
url = f"https://api.telegram.org/bot{bot_token}/sendPhoto"
files = {"photo": open(photo_path, "rb")}
data = {"chat_id": chat_id, "caption": "图片描述"}
resp = requests.post(url, files=files, data=data)
# Check response
if resp.status_code == 200:
print("Photo sent successfully!")
else:
print(f"Failed: {resp.text}")
- Open image in binary mode (
"rb") chat_idis required- Use
captionfor optional description - Handle encoding issues for special characters
Configuration
- Bot Token:
8610746914:AAHvbRYhGar_DD81-70IeWSSfkDLyvrWKY0
- Chat ID:
8422738233
- Photo Storage:
D:\mimoTool\photo\
Files
telegram_send_photo.py - Main script
Example
# Send a screenshot
photo_path = "D:\\mimoTool\\photo\\20260225_103159.png"
send_photo(photo_path, caption="截图")
8610746914:AAHvbRYhGar_DD81-70IeWSSfkDLyvrWKY08422738233D:\mimoTool\photo\telegram_send_photo.py- Main script
Example
# Send a screenshot
photo_path = "D:\\mimoTool\\photo\\20260225_103159.png"
send_photo(photo_path, caption="截图")
# Send a screenshot
photo_path = "D:\\mimoTool\\photo\\20260225_103159.png"
send_photo(photo_path, caption="截图")
正文来自原始发布页, 版权归作者所有,许可未标注。 权利人认为有不妥,可申请下架。