自建 Telegram Bot API

在使用本地服务器模式时

- 无大小限制地下载文件

- 可以上传最大为 2000 MB 的文件

- 支持通过本地路径和文件 URI 方案来上传文件

- max_webhook_connections 可达 100000

其中 api-idapi-hash 为你申请的 Telegram App 配置

▎方式 1: Docker 安装

services:
telegram-bot-api:
image: aiogram/telegram-bot-api:latest
container_name: telegram-bot-api
restart: always
environment:
TELEGRAM_LOCAL: true
TELEGRAM_API_ID: "xxx"
TELEGRAM_API_HASH: "yyy"
volumes:
- ./telegram-bot-api:/var/lib/telegram-bot-api
ports:
- 127.0.0.1:55522:8081


▎方式 2: 手动安装

按照 tdlib/telegram-bot-api 官方说明编译安装后, 创建一个服务

[Unit]
Description=telegram-bot-api
After=network.target
[Install]
WantedBy=multi-user.target
[Service]
Type=simple
WorkingDirectory=/root/telegram-bot-api
ExecStart=/usr/local/bin/telegram-bot-api -d /root/telegram-bot-api --temp-dir=/root/telegram-bot-api --local --api-id=xxx --api-hash=yyy -p 55522 --http-ip-address 127.0.0.1
Restart=always


systemctl daemon-reload; systemctl enable --now telegram-bot-api 启动

▎使用方式

http://127.0.0.1:55522 替换 https://api.telegram.org 即可

使用 https://api.telegram.org 时无法上传超过 50 MB 的文件, 使用本地 API 即可成功上传

相关内容 人形定时上传文件脚本

频道资源合集 恰饭推荐 群组

#Telegram #TG #bot #API #接口 #自建 #Docker #上传 #备份