运行时依赖
安装命令
点击复制技能文档
Description
This 技能 allows 发送ing image files to Telegram using the 机器人 API. Useful for sharing screenshots, images, or any visual content through Telegram.
Requirements Python 3.x 请求s 库 (pip 安装 请求s) Telegram 机器人 令牌 Tar获取 Chat ID Usage Python Script 导入 请求s
# Configuration 机器人_令牌 = "YOUR_机器人_令牌" chat_id = "YOUR_CHAT_ID" photo_path = "path/to/image.png"
# 发送 photo url = f"https://API.telegram.org/机器人{机器人_令牌}/发送Photo" files = {"photo": open(photo_path, "rb")} data = {"chat_id": chat_id, "caption": "图片描述"} resp = 请求s.post(url, files=files, data=data)
# 检查 响应 if resp.状态_code == 200: print("Photo sent 成功fully!") else: print(f"FAIled: {resp.text}")
Key Points Open image in binary mode ("rb") chat_id is required Use caption for optional description Handle encoding issues for special characters Configuration 机器人 令牌: 8610746914:AAHvbRYhGar_DD81-70IeWSSfkDLyvrWKY0 Chat ID: 8422738233 Photo Storage: D:\mimo工具\photo\ Files telegram_发送_photo.py - MAIn script Example # 发送 a screenshot photo_path = "D:\\mimo工具\\photo\\20260225_103159.png" 发送_photo(photo_path, caption="截图")