From 972c4af2102bc49ffa2091b1030817410f1fa443 Mon Sep 17 00:00:00 2001 From: Tonni Date: Thu, 11 Jun 2020 15:54:37 +0800 Subject: [PATCH] Initial public release. --- README.md | 12 +++++++----- package-lock.json | 38 +++++++++----------------------------- package.json | 4 ++-- src/Telegram.ts | 6 +++--- src/run.ts | 2 +- 5 files changed, 22 insertions(+), 40 deletions(-) diff --git a/README.md b/README.md index e304b8b..c42b277 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [![GitHub Actions][github-image]][github-url] [![TypeScript Style Guide][gts-image]][gts-url] -The newly rewritten project has a few advantages over the old: +The newly rewritten project has a few advantages over [the old one](https://github.com/HouCoder/tele-aria2/tree/legacy-python): 1. Fully touch based, more easy to use, no command required to use this bot. 2. Real time notification, it's now using Aria2's Websocket protocol to communicate. @@ -16,19 +16,20 @@ The newly rewritten project has a few advantages over the old: 1. Create your own bot and get its access token by using [@BotFather](https://telegram.me/botfather). 1. Get your unique user ID - https://stackoverflow.com/a/32777943/4480674. -1. (Optional) For mainland China users, be sure to have a socks proxy server running. +1. (Optional) For mainland China users, be sure to have a **HTTP** proxy up and running. 1. `$ npm install tele-aria2 -g`. 1. `$ tele-aria2 --help` to see how to get started. -## Configuration example +## Configuration file example ```json { "aria2Server": "ws://192.168.1.154:6800/jsonrpc", "aria2Key": "xxx", - "proxy": "socks://127.0.0.1:7891", + "proxy": "http://127.0.0.1:7890", "tgBot": "123456789:xxx", - "tgUser": 123456 + "tgUser": 123456, + "maxIndex": 10 } ``` @@ -56,6 +57,7 @@ No worries, just send your torrent file to chat! - [ ] Docker image - [ ] Unit testing +- [ ] Auto release to npm [npm-image]: https://img.shields.io/npm/v/tele-aria2.svg [npm-url]: https://npmjs.org/package/tele-aria2 diff --git a/package-lock.json b/package-lock.json index be26858..6aae56e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2095,6 +2095,15 @@ "integrity": "sha512-carPklcUh7ROWRK7Cv27RPtdhYhUsela/ue5/jKzjegVvXDqM2ILE9Q2BGn9JZJh1g87cp56su/FgQSzcWS8cQ==", "dev": true }, + "https-proxy-agent": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.0.tgz", + "integrity": "sha512-EkYm5BcKUGiduxzSt3Eppko+PiNWNEpa4ySk9vTC6wDsQJW9rHSa+UhGNJoRYp7bz6Ht1eaRIa6QaJqO5rCFbA==", + "requires": { + "agent-base": "6", + "debug": "4" + } + }, "human-signals": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-1.1.1.tgz", @@ -2257,11 +2266,6 @@ "side-channel": "^1.0.2" } }, - "ip": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/ip/-/ip-1.1.5.tgz", - "integrity": "sha1-vd7XARQpCCjAoDnnLvJfWq7ENUo=" - }, "is-arrayish": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", @@ -3468,30 +3472,6 @@ } } }, - "smart-buffer": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-4.1.0.tgz", - "integrity": "sha512-iVICrxOzCynf/SNaBQCw34eM9jROU/s5rzIhpOvzhzuYHfJR/DhZfDkXiZSgKXfgv26HT3Yni3AV/DGw0cGnnw==" - }, - "socks": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/socks/-/socks-2.3.3.tgz", - "integrity": "sha512-o5t52PCNtVdiOvzMry7wU4aOqYWL0PeCXRWBEiJow4/i/wr+wpsJQ9awEu1EonLIqsfGd5qSgDdxEOvCdmBEpA==", - "requires": { - "ip": "1.1.5", - "smart-buffer": "^4.1.0" - } - }, - "socks-proxy-agent": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/socks-proxy-agent/-/socks-proxy-agent-5.0.0.tgz", - "integrity": "sha512-lEpa1zsWCChxiynk+lCycKuC502RxDWLKJZoIhnxrWNjLSDGYRFflHA1/228VkRcnv9TIb8w98derGbpKxJRgA==", - "requires": { - "agent-base": "6", - "debug": "4", - "socks": "^2.3.3" - } - }, "spdx-correct": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.1.0.tgz", diff --git a/package.json b/package.json index fe06fff..0a74481 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tele-aria2", - "version": "0.1.0-beta.2", + "version": "0.1.0", "description": "Control your Aria2 server through Telegram", "homepage": "https://github.com/HouCoder/tele-aria2#tele-aria2", "main": "./dist/run.js", @@ -39,8 +39,8 @@ "@types/websocket": "^1.0.0", "@types/ws": "^7.2.5", "commander": "^5.1.0", + "https-proxy-agent": "^5.0.0", "needle": "^2.5.0", - "socks-proxy-agent": "^5.0.0", "telegraf": "^3.38.0", "typescript": "^3.9.5", "uuid": "^8.1.0", diff --git a/src/Telegram.ts b/src/Telegram.ts index b770f25..a37f6dc 100644 --- a/src/Telegram.ts +++ b/src/Telegram.ts @@ -1,4 +1,4 @@ -import { SocksProxyAgent } from 'socks-proxy-agent'; +import { HttpsProxyAgent } from 'https-proxy-agent'; import Telegraf, { Markup, Context } from 'telegraf'; import needle, { NeedleResponse } from 'needle'; import winston from 'winston'; @@ -19,7 +19,7 @@ export default class Telegram { private maxIndex: number; - private agent: SocksProxyAgent | undefined; + private agent: HttpsProxyAgent | undefined; constructor(options: { tgBot: string; @@ -35,7 +35,7 @@ export default class Telegram { this.logger = options.logger; if (options.proxy) { - this.agent = new SocksProxyAgent(options.proxy); + this.agent = new HttpsProxyAgent(options.proxy); } this.bot = this.connect2Tg({ diff --git a/src/run.ts b/src/run.ts index e472bc6..509a0f0 100644 --- a/src/run.ts +++ b/src/run.ts @@ -19,7 +19,7 @@ program .option('-b, --tg-bot ', 'Telegram bot key') // eslint-disable-next-line max-len .option('-u, --tg-user ', 'Telegram user ID, see here to get your ID - https://stackoverflow.com/a/32777943/4480674') - .option('-p, --proxy ', 'Access Telegram server through a proxy') + .option('-p, --proxy ', 'Access Telegram server through a HTTP proxy') .option('-m, --max-index ', 'Max items in the range of [1, max-index], default 20') .option('-c, --config ', 'Load options from a JSON config file') .option('-V, --version', 'Output the current version')