npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@onebots/adapter-telegram

v1.0.0

Published

onebots Telegram适配器

Readme

@onebots/adapter-telegram

onebots Telegram 适配器,支持代理访问。

安装

npm install @onebots/adapter-telegram grammy
# 或
pnpm add @onebots/adapter-telegram grammy

配置

config.yaml 中配置:

telegram.your_bot_id:
  token: "YOUR_BOT_TOKEN"
  
  # 代理配置(可选,用于访问 Telegram API)
  proxy:
    url: "http://127.0.0.1:7890"  # 或 socks5://127.0.0.1:1080
    # username: "user"  # 可选
    # password: "pass"  # 可选
  
  # 轮询模式(默认)
  polling:
    enabled: true
    timeout: 30
    limit: 100
  # 或 Webhook 模式
  # webhook:
  #   url: "https://your-domain.com/webhook"
  #   secret_token: "your_secret_token"
  #   allowed_updates: ["message", "callback_query"]

代理配置说明

| 配置项 | 类型 | 必填 | 说明 | |--------|------|------|------| | proxy.url | string | 是 | 代理服务器地址 | | proxy.username | string | 否 | 代理用户名 | | proxy.password | string | 否 | 代理密码 |

支持的代理类型:

  • HTTP 代理:http://host:port
  • HTTPS 代理:https://host:port

使用

onebots -r telegram

功能

  • ✅ 私聊消息收发
  • ✅ 群组消息收发
  • ✅ 频道消息收发
  • ✅ 图片、视频、音频、文件发送
  • ✅ 消息编辑和删除
  • ✅ 群组管理(获取信息、踢出成员等)
  • ✅ Inline Keyboard 支持(通过 Callback Query)
  • ✅ 命令处理(/command)
  • 代理支持(HTTP/HTTPS)

获取 Bot Token

  1. 在 Telegram 中搜索 @BotFather
  2. 发送 /newbot 创建新机器人
  3. 按照提示设置机器人名称和用户名
  4. 获取 Bot Token

依赖说明

| 依赖 | 何时需要 | 安装命令 | |------|----------|----------| | grammy | 必需 | npm install grammy | | https-proxy-agent | 使用代理时 | npm install https-proxy-agent |

常见问题

1. 连接超时 / Network request failed

如果你在中国大陆等需要代理的地区访问 Telegram API,请配置代理:

telegram.your_bot:
  token: 'xxx'
  proxy:
    url: "http://127.0.0.1:7890"  # 你的代理地址

并安装代理依赖:

npm install https-proxy-agent

2. 代理配置后仍然超时

  1. 确认代理服务正常运行
  2. 检查代理地址和端口是否正确
  3. 确认代理服务允许访问 api.telegram.org

可以用以下命令测试代理:

curl -x http://127.0.0.1:7890 https://api.telegram.org/bot<TOKEN>/getMe

3. 缺少 https-proxy-agent 警告

如果看到 https-proxy-agent 未安装 警告但你需要代理:

npm install https-proxy-agent

相关链接