Skip to content

uuid2023/telechan

 
 

Repository files navigation

TeleChan - message api for telegram bot

How to use

  1. star and fork this repo
  2. goto https://vercel.com/ create a new project, select the repo just created
  3. add BotFather in telegram, create new bot and get telegram api token
  4. set output dir to dist , set BOT_TOKEN to telegram api token, set TCKEY a random string image
  5. deploy
  6. send /sendkey command to the bot, you will get sendkey and api url

API

Both HTTP GET or POST are OK

  • sendkey,required
  • text,required
  • desp,optional

text and desp support telegram markdown which is a very small subset of markdown without image support

send function

function tg_send(  $text , $desp = '' , $key = '<sendkey>'  )
{
    $postdata = http_build_query( array( 'text' => $text, 'desp' => $desp ));
    $opts = array('http' =>
    array(
        'method'  => 'POST',
        'header'  => 'Content-type: application/x-www-form-urlencoded',
        'content' => $postdata));
    
    $context  = stream_context_create($opts);
    return $result = file_get_contents('telechan8.vercel.app/api/send?sendkey='.$key, false, $context);
 
}

Thanks

Heavily modified base Telegram Bot Boilerplate with Vercel's Serverless Functions

中文教程

image

安装视频@B站,欢迎关注作者

参数说明:

  • sendkey,required
  • text,required
  • desp,optional

仅支持部分 Markdown 语法,任何不兼容以下语法的的提交,都会导致 400 错误。注意不支持图片,注意不支持图片,注意不支持图片:

    *bold \*text*
    _italic \*text_
    __underline__
    ~strikethrough~
    *bold _italic bold ~italic bold strikethrough~ __underline italic bold___ bold*
    [inline URL](http://www.example.com/)
    [inline mention of a user](tg://user?id=123456789)
    `inline fixed-width code`
    ```
    pre-formatted fixed-width code block
    ```
    ```python
    pre-formatted fixed-width code block written in the Python programming language
    ```

About

message api for telegram bot

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 98.2%
  • Shell 1.8%