/telegram-bot-api

Telegram Bot API server

Primary LanguageC++Boost Software License 1.0BSL-1.0

Telegram Bot API on Unix Socket

The Telegram Bot API provides an HTTP API for creating Telegram Bots.

If you've got any questions about bots or would like to report an issue with your bot, kindly contact us at @BotSupport in Telegram.

Please note that only global Bot API issues that affect all bots are suitable for this repository.

Table of Contents

Installation

In general, you need to install all Telegram Bot API server dependencies and compile the source code using CMake:

git clone --recursive https://github.com/ibrohimislam/telegram-bot-api.git
cd telegram-bot-api
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
cmake --build . --target install

Usage

specify the unix domain socket location such i.e. ./telegram-bot-api.sock using --unix-socket param:

./telegram-bot-api -v 5 --api-id=$API_ID --api-hash=$API_HASH --unix-socket=./telegram-bot-api.sock --local

to check the unix socket use curl with --unix-socket param:

curl --unix-socket ./telegram-bot-api.sock http://localhost/bot$BOT_TOKEN/getMe

in NodeJS undici you can set the agent parameter:

import { fetch, Agent } from 'undici'

const BOT_TOKEN = "dummy-bot-token"
const resp = await fetch(`http://localhost/bot${BOT_TOKEN}/getMe`, {
  dispatcher: new Agent({
    connect: {
      socketPath: './telegram-bot-api.sock'
    }
  })
})

console.log(await resp.json())

License

Telegram Bot API server source code is licensed under the terms of the Boost Software License. See LICENSE_1_0.txt for more information.