Skip to content

Add sendPhotoFromUrl endpoint for uploading media from URL to groups#12

Draft
Copilot wants to merge 2 commits into
mainfrom
copilot/fix-11
Draft

Add sendPhotoFromUrl endpoint for uploading media from URL to groups#12
Copilot wants to merge 2 commits into
mainfrom
copilot/fix-11

Conversation

Copilot AI commented Jul 24, 2025

Copy link
Copy Markdown

This PR implements a new feature that allows users to send images from URLs directly to Telegram groups through the Cloudflare Worker proxy.

🚀 New Feature: sendPhotoFromUrl

Endpoint: POST /bot{token}/sendPhotoFromUrl

Required Parameters:

  • url: Direct URL to the image file
  • chat_id: Group or user chat ID to send the image to

Optional Parameters:

  • caption: Caption text for the image
  • parse_mode: Parse mode for caption (HTML, Markdown, etc.)

📋 Example Usage

fetch('https://your-worker.workers.dev/botYOUR_BOT_TOKEN/sendPhotoFromUrl', {
    method: 'POST',
    headers: {
        'Content-Type': 'application/json',
    },
    body: JSON.stringify({
        url: "https://example.com/image.jpg",
        chat_id: "-1001234567890",
        caption: "<b>Image from URL</b>\nSent using the proxy!",
        parse_mode: "HTML"
    })
})
.then(response => response.json())
.then(data => console.log(data));

🔧 Technical Implementation

  • Minimal changes: Added 86 lines of new functionality while preserving all existing proxy behavior
  • Comprehensive validation: URL format checking, required parameter validation, and image URL detection
  • Error handling: Proper error responses for invalid URLs, missing parameters, and network issues
  • CORS support: Maintains existing CORS headers for web applications
  • Integration: Uses Telegram's native sendPhoto API with URL support

📚 Documentation Updates

  • Updated inline HTML documentation with interactive examples
  • Enhanced README.md with Vietnamese usage instructions
  • Added code examples and parameter descriptions

🧪 Testing

  • URL validation logic tested and verified
  • Endpoint routing confirmed working correctly
  • Parameter validation implemented and tested
  • Code syntax validation passed

Feature Demo

The feature is ready for production deployment and maintains full backward compatibility with existing functionality.

Fixes #11.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

…roups

Co-authored-by: tuanpb99 <32542477+tuanpb99@users.noreply.github.com>
Copilot AI changed the title [WIP] Upload Media From Url To Group Add sendPhotoFromUrl endpoint for uploading media from URL to groups Jul 24, 2025
Copilot AI requested a review from tuanpb99 July 24, 2025 10:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Upload Media From Url To Group

2 participants