{"id":22071510,"url":"https://github.com/astrian/tglambot","last_synced_at":"2025-10-03T14:16:36.244Z","repository":{"id":81824178,"uuid":"146247471","full_name":"Astrian/tglambot","owner":"Astrian","description":"Telegram 留言助理机器人，让 +86 手机号用户可以在 Telegram 上给你留言。","archived":false,"fork":false,"pushed_at":"2018-08-29T01:22:23.000Z","size":48,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-17T17:26:58.412Z","etag":null,"topics":["telegram"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Astrian.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-08-27T04:38:10.000Z","updated_at":"2020-12-11T16:03:29.000Z","dependencies_parsed_at":null,"dependency_job_id":"8f55808d-ef76-408d-b3a0-5b4b014e1b87","html_url":"https://github.com/Astrian/tglambot","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Astrian/tglambot","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Astrian%2Ftglambot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Astrian%2Ftglambot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Astrian%2Ftglambot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Astrian%2Ftglambot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Astrian","download_url":"https://codeload.github.com/Astrian/tglambot/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Astrian%2Ftglambot/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266820495,"owners_count":23989805,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-24T02:00:09.469Z","response_time":99,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["telegram"],"created_at":"2024-11-30T20:31:57.765Z","updated_at":"2025-10-03T14:16:31.195Z","avatar_url":"https://github.com/Astrian.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"*English version. For Chinese instruction, just scroll down the page.*\n\n# Telegram “leave a message” bot\nIn 2018, Telegram make “private chat to strangers” function disabled for Chinese user (with +86 phone number). So if you want your Chinese friend to contact you directly, you can config this bot, and your friend can leave a message to you with it.\n\n## Manual building\n\u003e You can build the bot with docker. See “Build with Docker” part.\n\nFirst, chat to [Bot Father](https://t.me/botfather), and request to make a new bot (by send `/newbot` to him). Then, Bot Father will give you a bot token seems like `123456789:ABCDEFGhijklmnOPQRSTuvwxyz012345678`.\n\nNext, you will need a VPS and a domain to build this bot (DigitalOcean VPS with Ubuntu OS is recommended).\n\nFollow these steps to config:\n\n1. Set a `A` or `AAAA` DNS record to your domain with your VPS IP address. In this tutorial, I will use `helper.example.com` domain for example.\n2. Connect to your VPS with SSH.\n3. Install Git, Node.js, Nginx and [Certbot](https://certbot.eff.org/). Note Certbot (with Let's Encrypt) is a good way to config SSL and HTTPS, but you still can config HTTPS by your self.\n4. `git clone https://github.com/Astrian/tglambot.git` or `git clone https://gitlab.com/Astrian/tglambot.git`\n5. Duplicate `config.sample.js` and rename the new file to `config.js`. Edit the new `config.js` with your Telegram, domain, and Instapaper (optional) information. (See config sample below)\n6. Config nginx by `vi /etc/nginx/sites-available/default`. See config sample below to know how to config.\n7. Config HTTPS with `sudo certbot --nginx`. Follow the instructions to config it (and it's super easy, really).\n8. `npm install` and `npm start`, and `/start` the bot. Then tell your friend to chat with bot, the message will be forwarded to you.\n\n## Config sample\n`config.js`:\n\n```\nmodule.exports = {\n  telegram: {\n    bot_token: '123456789:ABCDEFGhijklmnOPQRSTuvwxyz012345678',\n    user_id: 12345678, // Get it with https://t.me/get_id_bot,\n    start_msg: 'hello world' // When your friends /start the bot, this text message will be sent to them.\n  },\n  instapaper: { // That information is optional. If you don't need it, just make them as empty strings.\n    username: 'someone@example.com',\n    password: 'mYiNst4P4perPassw0rd'\n  },\n  url: {\n    domain: 'https://helper.example.com', // MUST USE HTTPS, don't left slash at the end of it.\n    path: '/helloworld' // Start with slash，Telegram recommends use a long random strings to keep your bot safe.\n  }\n};\n```\n\nNginx config:\n\n```\nserver {\n  server_name helper.example.com;\n  location / {\n    proxy_pass http://localhost:3001;\n  }\n  listen 80;\n}\n```\n\n## Build with Docker (Beta)\n\u003e It's a new way to build the bot, and this way is not be verified in production environments. Feel free to submit an issue if you find any problem when build with Docker.\n\nFirst, you still need a domain name, an VPS and a Telegram bot token (see last part).\n\nThen...\n\n```\ndocker pull astrian/tglambot\ndocker image build -t astrian/tglambot .\ndocker container run -p 8000:3001 -it astrian/tglambot\n```\n\nWhen you run the last one command, you will see `node` will throw errors.\n\nDon't worry. Let's create a `config.js` file, copy the [config code](https://github.com/Astrian/tglambot/blob/master/config.sample.js), and `docker cp config.js \u003ccontainer name\u003e:/`\n\nStart the container again. Great! It's running. Now you just need to config the Nginx with 8000 port and config the SSL and HTTPS.\n\n## ... by the way\nI make a little Instapaper function in this bot.\n\nYou can config your Instapaper username and password, then send or forward message with URLs to it, it will send the link to your Instapaper inbox.\n\nBut if you don't need it, just feel free to leave the strings blank.\n\n## License\nMIT\n\n-----\n\n*中文*\n\n# Telegram 私聊助理机器人\n2018 年，Telegram 封禁中国用户（+86 手机）的私聊陌生人功能。如果你有让中国手机号用户私聊你的需求，可以尝试这款 bot。\n\n## 手动构建机器人\n\u003e 你可以使用 Docker 进行自动化构建，详见「使用 Docker 构建」一节。\n\n请先私聊 [Bot Father](https://t.me/botfather)，向他申请一个新的 bot（发送 `/newbot` 指令给他）。你会获得形如 `123456789:ABCDEFGhijklmnOPQRSTuvwxyz012345678` 的 token。\n\n接着，你需要申请一个 VPS 和域名。推荐使用 DigitalOcean VPS 服务以及 Ubuntu 操作系统。VPS 需要能够访问 Telegram 服务器。\n\n根据以下步骤进行配置。\n\n1. 向你的域名登记一个指向你的 VPS 服务器的 `A` 或 `AAAA` DNS 记录。在本篇教程中，将会用 `helper.example.com` 作为域名例子。\n2. 使用 SSH 进入你的 VPS。\n3. 安装 Git、Node.js、Nginx 以及 [Certbot](https://certbot.eff.org/)。注意，Certbot（和 Let's Encrypt 证书服务）是推荐使用的 HTTPS 及 SSL 签证服务，但你也可以使用自己的证书服务进行配置。\n4. `git clone https://github.com/Astrian/tglambot.git` 或者 `git clone https://gitlab.com/Astrian/tglambot.git`\n5. 复制 `config.sample.js` 并将新文件命名为 `config.js`。编辑新的 `config.js` 文件，将你的 Telegram、域名和 Instapaper（可选）配置写入，参见下面的配置示例。\n6. 使用 `vi /etc/nginx/sites-available/default` 配置 Nginx。参见下面的配置示例。\n7. 使用 `sudo certbot --nginx` 指令进行签证。这一步只需要跟着命令行提示就行（超超超简单）。\n8. `npm install` 之后再 `npm start`，然后向你的 bot 发送 `/start`。接着，你的好友就可以通过这款 bot 向你留言。\n\n## 配置示例\n`config.js`：\n\n```\nmodule.exports = {\n  telegram: {\n    bot_token: '123456789:ABCDEFGhijklmnOPQRSTuvwxyz012345678',\n    user_id: 12345678, // 可以从 https://t.me/get_id_bot 获取。\n    start_msg: 'hello world' // 当别人 /start 你的 bot 的时候，这条文字消息将回复给他们。\n  },\n  instapaper: { // 可选项。如果不需要 Instapaper 相关功能，将它们留空。\n    username: 'someone@example.com',\n    password: 'mYiNst4P4perPassw0rd'\n  },\n  url: {\n    domain: 'https://helper.example.com', // 必须使用 HTTPS，不要以斜杠结尾。\n    path: '/helloworld' // 请以斜杠开头，Telegram 推荐使用随机字符串以保证你的 bot 安全（不被他人伪造请求滥用）。\n  }\n};\n```\n\nNginx 配置：\n\n```\nserver {\n  server_name helper.example.com;\n  location / {\n    proxy_pass http://localhost:3001;\n  }\n  listen 80;\n}\n```\n\n## 使用 Docker 构建（测试版）\n\u003e 这是配置机器人的新方式，但这个方式还没在生产环境中进行使用。发现任何问题，请向我提出 issue。\n\n首先，你还是需要一个域名、VPS，以及一个 Telegram 机器人 token（参见上一节）。\n\n然后……\n\n```\ndocker pull astrian/tglambot\ndocker image build -t astrian/tglambot .\ndocker container run -p 8000:3001 -it astrian/tglambot\n```\n\n运行最后一个指令时，你会发现 `node` 会抛出一些错误。\n\n不用担心，我们只需新建一个 `config.js` 文件，然后复制[配置代码](https://github.com/Astrian/tglambot/blob/master/config.sample.js)，保存后将它复制到 Docker 容器中：`docker cp config.js \u003ccontainer name\u003e:/`\n\n完成后，重新启动容器，你会发现它已经正常工作了。现在，你可以在 Nginx 配置 8000 的反向代理，并配置 SSL 和 HTTPS，就可以正常使用机器人了。\n\n## 还有件事\n代码里有一个 Instapaper 集成功能。\n\n配置好你的 Instapaper 用户名密码之后，可以向 bot 直接发送或转发 URL 链接，链接就会自动存在你的 Instapaper。\n\n如果不需要，只需要在配置中将 Instapaper 相关字段留空。\n\n## 协议\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fastrian%2Ftglambot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fastrian%2Ftglambot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fastrian%2Ftglambot/lists"}