โ† Back to Skills Marketplace
bustes01

๐Ÿ“ค Telegram File Sender

by shake27 ยท GitHub โ†— ยท v1.0.0 ยท MIT-0
cross-platform โœ“ Security Clean
96
Downloads
1
Stars
0
Active Installs
1
Versions
Install in OpenClaw
/install tg-file-sender
Description
Send local files directly to Telegram chat. Supports documents, photos, and other media types. Use when user says: "send this file to me", "send to telegram"...
README (SKILL.md)

๐Ÿ“ค Telegram File Sender

Send local files directly to a Telegram chat using the Bot API. The bot token is read from environment variable TG_BOT_TOKEN โ€” never hardcoded or logged.

Prerequisites

  • TG_BOT_TOKEN environment variable must be set
  • curl must be available
  • The target chat must have started a conversation with the bot

Usage

Step 1: Resolve File Path

Accept a file path from the user. Resolve it relative to the workspace:

FILE_PATH="\x3Cworkspace>/\x3Cuser-provided-path>"

Security rules:

  • Resolve to absolute path using realpath
  • Reject if path does not start with the workspace root
  • Reject if file does not exist
  • Reject if file is a symlink (avoid directory traversal)
  • Reject if file size > 50 MB (Telegram document limit)

Step 2: Detect File Type

Use the file extension to determine the appropriate Telegram method:

Extension Method Caption support
.jpg .jpeg .png .gif .webp sendPhoto โœ… Yes
.mp4 .mov .avi .webm sendVideo โœ… Yes
.mp3 .ogg .wav .flac sendAudio โœ… Yes
Others (.xlsx, .pdf, .md, .zip, etc.) sendDocument โœ… Yes

Step 3: Send via Bot API

BOT_TOKEN="$TG_BOT_TOKEN"
CHAT_ID="\x3Ctarget chat ID>"
FILE_PATH="\x3Cresolved absolute path>"
CAPTION="\x3Coptional description>"

curl -s -X POST "https://api.telegram.org/bot${BOT_TOKEN}/sendDocument" \
  -F chat_id="$CHAT_ID" \
  -F document=@"$FILE_PATH" \
  -F caption="$CAPTION"

For photos:

curl -s -X POST "https://api.telegram.org/bot${BOT_TOKEN}/sendPhoto" \
  -F chat_id="$CHAT_ID" \
  -F photo=@"$FILE_PATH" \
  -F caption="$CAPTION"

Step 4: Handle Response

Parse the JSON response:

  • If ok: true โ†’ confirm delivery: "โœ… ๆ–‡ไปถๅทฒๅ‘้€"
  • If ok: false โ†’ report the description field to the user

Privacy & Security Guidelines

  1. Token protection: Never log, echo, or display the bot token value. Use $TG_BOT_TOKEN only in the API call URL.
  2. Path traversal prevention: Always resolve with realpath and verify the result starts with the workspace root.
  3. No content logging: Do not log file contents or read file contents for any purpose beyond sending.
  4. Size limit: Enforce 50 MB maximum (Telegram Bot API limit for documents).
  5. User confirmation: For files > 10 MB, warn the user about size before sending.
  6. Chat ID: Use the chat_id from the session context. Never prompt the user for a chat ID.
  7. Ephemeral files: If the file is in /tmp/, clean up after sending.

Behavior Rules

  • If TG_BOT_TOKEN is unset โ†’ tell the user: "่ฏทๅ…ˆ่ฎพ็ฝฎ TG_BOT_TOKEN ็Žฏๅขƒๅ˜้‡"
  • If the file doesn't exist โ†’ "ๆ–‡ไปถไธๅญ˜ๅœจ๏ผŒ่ฏทๆฃ€ๆŸฅ่ทฏๅพ„"
  • If the file is outside workspace โ†’ "่ทฏๅพ„ไธๅœจๅทฅไฝœ็›ฎๅฝ•่Œƒๅ›ดๅ†…๏ผŒๅทฒๆ‹’็ป"
  • If the file exceeds 50 MB โ†’ "ๆ–‡ไปถ่ถ…่ฟ‡ 50MB๏ผŒTelegram ไธๆ”ฏๆŒๅ‘้€"
  • If the API returns an error โ†’ show the error description to the user

๐Ÿ“ค Telegram ๆ–‡ไปถๅ‘้€ๅ™จ

้€š่ฟ‡ Telegram Bot API ๅฐ†ๆœฌๅœฐๆ–‡ไปถ็›ดๆŽฅๅ‘้€ๅˆฐ่Šๅคฉ็ช—ๅฃใ€‚Bot Token ไปŽ็Žฏๅขƒๅ˜้‡ TG_BOT_TOKEN ่ฏปๅ–๏ผŒ็ปไธ็กฌ็ผ–็ ๆˆ–ๅ†™ๅ…ฅๆ—ฅๅฟ—ใ€‚

ๅ‰ๆๆกไปถ

  • ้œ€่ฎพ็ฝฎ TG_BOT_TOKEN ็Žฏๅขƒๅ˜้‡
  • ้œ€ๅฎ‰่ฃ… curl
  • ็›ฎๆ ‡่Šๅคฉๅฏน่ฑก้œ€ๅทฒไธŽ bot ๆœ‰่ฟ‡ๅฏน่ฏ

ไฝฟ็”จๆ–นๆณ•

็ฌฌไธ€ๆญฅ๏ผš่งฃๆžๆ–‡ไปถ่ทฏๅพ„

ๆŽฅๆ”ถ็”จๆˆทๆไพ›็š„่ทฏๅพ„๏ผŒ็›ธๅฏนไบŽๅทฅไฝœ็›ฎๅฝ•่งฃๆž๏ผš

FILE_PATH="\x3Cworkspace>/\x3C็”จๆˆทๆไพ›็š„่ทฏๅพ„>"

ๅฎ‰ๅ…จๆฃ€ๆŸฅ๏ผš

  • ็”จ realpath ่งฃๆžไธบ็ปๅฏน่ทฏๅพ„
  • ๆ‹’็ปไธๅœจๅทฅไฝœ็›ฎๅฝ•่Œƒๅ›ดๅ†…็š„่ทฏๅพ„
  • ๆ‹’็ปไธๅญ˜ๅœจ็š„ๆ–‡ไปถ
  • ๆ‹’็ป็ฌฆๅท้“พๆŽฅ๏ผˆ้˜ฒๆญข็›ฎๅฝ•็ฉฟ่ถŠ๏ผ‰
  • ๆ‹’็ปๅคงไบŽ 50MB ็š„ๆ–‡ไปถ

็ฌฌไบŒๆญฅ๏ผš่ฏ†ๅˆซๆ–‡ไปถ็ฑปๅž‹

ๆ นๆฎๆ‰ฉๅฑ•ๅ้€‰ๆ‹ฉๅ‘้€ๆ–นๅผ๏ผš

ๆ‰ฉๅฑ•ๅ ๆ–นๆณ• ๆ”ฏๆŒๆ ‡้ข˜
.jpg .jpeg .png .gif .webp sendPhoto โœ… ๆ˜ฏ
.mp4 .mov .avi .webm sendVideo โœ… ๆ˜ฏ
.mp3 .ogg .wav .flac sendAudio โœ… ๆ˜ฏ
ๅ…ถไป–๏ผˆ.xlsx .pdf .md .zip ็ญ‰๏ผ‰ sendDocument โœ… ๆ˜ฏ

็ฌฌไธ‰ๆญฅ๏ผš้€š่ฟ‡ Bot API ๅ‘้€

BOT_TOKEN="$TG_BOT_TOKEN"
CHAT_ID="\x3C็›ฎๆ ‡่ŠๅคฉID>"
FILE_PATH="\x3C่งฃๆžๅŽ็š„็ปๅฏน่ทฏๅพ„>"
CAPTION="\x3Cๅฏ้€‰ๆ่ฟฐ>"

curl -s -X POST "https://api.telegram.org/bot${BOT_TOKEN}/sendDocument" \
  -F chat_id="$CHAT_ID" \
  -F document=@"$FILE_PATH" \
  -F caption="$CAPTION"

็ฌฌๅ››ๆญฅ๏ผšๅค„็†ๅ“ๅบ”

่งฃๆž JSON ๅ“ๅบ”๏ผš

  • ok: true โ†’ ็กฎ่ฎคๅ‘้€๏ผš"โœ… ๆ–‡ไปถๅทฒๅ‘้€"
  • ok: false โ†’ ๅ‘็”จๆˆทๅฑ•็คบ description ๅญ—ๆฎตไธญ็š„้”™่ฏฏไฟกๆฏ

้š็งไธŽๅฎ‰ๅ…จ่ง„่Œƒ

  1. Token ไฟๆŠค๏ผš ็ปไธๆ‰“ๅฐใ€่ฎฐๅฝ•ๆˆ–ๆ˜พ็คบ bot tokenใ€‚ไป…ๅœจ API ่ฐƒ็”จ URL ไธญไฝฟ็”จ $TG_BOT_TOKEN
  2. ่ทฏๅพ„็ฉฟ่ถŠ้˜ฒๆŠค๏ผš ๅง‹็ปˆ็”จ realpath ่งฃๆž๏ผŒ้ชŒ่ฏ็ป“ๆžœไปฅๅทฅไฝœ็›ฎๅฝ•ๅผ€ๅคด
  3. ไธ่ฎฐๅฝ•ๅ†…ๅฎน๏ผš ไธ่ฏปๅ–ๆˆ–่ฎฐๅฝ•ๆ–‡ไปถๅ†…ๅฎน
  4. ๅคงๅฐ้™ๅˆถ๏ผš ไธŠ้™ 50MB
  5. ๅคงๆ–‡ไปถๆ้†’๏ผš ๅคงไบŽ 10MB ๆ—ถๆ้†’็”จๆˆท
  6. Chat ID๏ผš ไปŽไผš่ฏไธŠไธ‹ๆ–‡่Žทๅ–๏ผŒไธๅ‘็”จๆˆท่ฏข้—ฎ
  7. ไธดๆ—ถๆ–‡ไปถ๏ผš /tmp ไธ‹็š„ๆ–‡ไปถๅ‘้€ๅŽๆธ…็†

่กŒไธบ่ง„ๅˆ™

  • TG_BOT_TOKEN ๆœช่ฎพ็ฝฎ โ†’ "่ฏทๅ…ˆ่ฎพ็ฝฎ TG_BOT_TOKEN ็Žฏๅขƒๅ˜้‡"
  • ๆ–‡ไปถไธๅญ˜ๅœจ โ†’ "ๆ–‡ไปถไธๅญ˜ๅœจ๏ผŒ่ฏทๆฃ€ๆŸฅ่ทฏๅพ„"
  • ่ทฏๅพ„ไธๅœจๅทฅไฝœ็›ฎๅฝ•ๅ†… โ†’ "่ทฏๅพ„ไธๅœจๅทฅไฝœ็›ฎๅฝ•่Œƒๅ›ดๅ†…๏ผŒๅทฒๆ‹’็ป"
  • ๆ–‡ไปถ่ถ…่ฟ‡ 50MB โ†’ "ๆ–‡ไปถ่ถ…่ฟ‡ 50MB๏ผŒTelegram ไธๆ”ฏๆŒๅ‘้€"
  • API ่ฟ”ๅ›ž้”™่ฏฏ โ†’ ๅฐ†้”™่ฏฏๆ่ฟฐๅฑ•็คบ็ป™็”จๆˆท
Usage Guidance
This result is low confidence because the local sandbox prevented reading metadata.json and artifact files. Re-run the review where the artifact directory is readable before installing or approving the skill.
Capability Assessment
โ„น Purpose & Capability
Not assessable from artifacts because local file inspection failed before metadata.json or artifact contents could be read.
โ„น Instruction Scope
Not assessable from artifacts because SKILL.md and related files were unavailable to the reviewer.
โ„น Install Mechanism
Not assessable from artifacts because install specifications could not be inspected.
โ„น Credentials
Not assessable from artifacts because capability signals and file contents could not be read.
โ„น Persistence & Privilege
Not assessable from artifacts because no persistence, credential, or privilege evidence was accessible.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install tg-file-sender
  3. After installation, invoke the skill by name or use /tg-file-sender
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.0.0
Initial release: send local files via Telegram Bot API with path security checks
Metadata
Slug tg-file-sender
Version 1.0.0
License MIT-0
All-time Installs 0
Active Installs 0
Total Versions 1
Frequently Asked Questions

What is ๐Ÿ“ค Telegram File Sender?

Send local files directly to Telegram chat. Supports documents, photos, and other media types. Use when user says: "send this file to me", "send to telegram"... It is an AI Agent Skill for Claude Code / OpenClaw, with 96 downloads so far.

How do I install ๐Ÿ“ค Telegram File Sender?

Run "/install tg-file-sender" in the OpenClaw or Claude Code chat to install it in one step โ€” no extra setup required.

Is ๐Ÿ“ค Telegram File Sender free?

Yes, ๐Ÿ“ค Telegram File Sender is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does ๐Ÿ“ค Telegram File Sender support?

๐Ÿ“ค Telegram File Sender is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created ๐Ÿ“ค Telegram File Sender?

It is built and maintained by shake27 (@bustes01); the current version is v1.0.0.

๐Ÿ’ฌ Comments