Skip to content

Commit 6ac59d4

Browse files
committed
chore: release 4.5.7
1 parent 7eb772b commit 6ac59d4

10 files changed

+644
-596
lines changed

CHANGELOG.md

+20
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,24 @@
11
# Changelog
2+
## [v4.5.7](https://github.com/jipaix/xdccjs/tree/v4.5.6)
3+
### Feat(cli)
4+
* add `message` event to jobs
5+
### Feat(lib+cli)
6+
* messages sent by the current job's bot are printed out
7+
* add `queue` constructor parameters (CLI: `--queue`) which expect a regex to detect if the bot has moved you to a queue
8+
```console
9+
xdccJS --host "irc.server.com" --bot "SOME_BOT" --download "1-100" --queue "/download(.*)\d+\sout\sof\s\d+\/gi"
10+
# will match strings like : download "[somestuff] some files.pdf" pending, 10 out of 30
11+
```
12+
```js
13+
params.queue = /download(.*)\d+\sout\sof\s\d+\/gi
14+
```
15+
### Fix(lib+cli)
16+
* crashing when running in a non-TTY environment
17+
* download bar not rendering new lines when a download is interrupted
18+
### Fix(lib)
19+
* cancel message/event wasn't triggered if there was no active downloads
20+
```
21+
---
222
## [v4.5.0](https://github.com/jipaix/xdccjs/tree/v4.5.0)
323
### Fix(lib+cli)
424
* add option to allow/reject connection on TLS enabled server with self-signed certificates

README.md

+35-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ It can also be used as a <a href="#command-line-interface">command-line</a> down
1515
- [Getting Started](#getting-started)
1616
- [List of options](#options)
1717
- [Download](#download)
18+
- [Download queue detection](#download-queue-detection)
1819
- [Jobs](#jobs)
1920
- [Events](#events)
2021
- [Piping](#pipes)
@@ -86,6 +87,7 @@ const opts = {
8687
randomizeNick: false, // Add random numbers at end of nickname - default: true
8788
passivePort: [5000, 5001, 5002], // Array of port(s) to use with Passive DCC - default: [5001]
8889
botNameMatch: false, // Block downloads if the bot's name does not match the request - default: true
90+
queue: /soMething(.*)maTching/g // Regex matching the bot's message when you're request is moved to a queue
8991
}
9092
```
9193
### Download
@@ -99,6 +101,25 @@ xdccJS.on('ready', async () => {
99101
const purple = await xdccJS.download('XDCC|PURPLE', ['1', '3', '10', '20'])
100102
})
101103
```
104+
#### Download queue detection
105+
xdccJS will timeout any request after a certain amount of time when no file is sent (see [Options.timeout](#options)), Which is exactly what happens when a bot puts you into queue.
106+
107+
To avoid this behavior you need to provide a [regex](https://www.w3schools.com/jsref/jsref_obj_regexp.asp) matching the bot "queue message".
108+
109+
```js
110+
const opts = {
111+
host: 'irc.server.com',
112+
timeout: 20 // defaut is 30
113+
queue: /request(.*)queued(.*)\d+\/\d+$/g
114+
//=> excepted bot queue message: "Your request has been queued: position x/x"
115+
}
116+
const xdccJS = new XDCC(opts)
117+
118+
xdccJS.on('ready', async () =>{
119+
const queued = await xdccJS.download('BOT_WITH_LARGE_QUEUE', '1-5')
120+
//=> if the bot sends a message matching the regex, download won't fail
121+
})
122+
```
102123
### Jobs
103124
`Job`s are `download()` instances which are tied to the target nickname.
104125
calling `download()` multiple times for the same target will update current job.
@@ -237,6 +258,12 @@ const arrayOfJobs = await xdccJS.jobs()
237258
console.log(fileInfo) //=> { file: 'filename.pdf', filePath: 'pipe', length: 5844849 }
238259
})
239260
```
261+
> [**Job**].on( **'cancel'** ) : *Job canceled by user*
262+
- ```js
263+
job.on('cancel', (message) => {
264+
console.error(message) //=> "cancelled by user"
265+
})
266+
```
240267
### Pipes
241268
In order to use pipes xdccJS need to be initialized with path option set to false
242269
```js
@@ -309,6 +336,7 @@ Options:
309336
--no-randomize Disable nickname randomization
310337
-w, --wait [number] Wait time (in seconds) in channel(s) before sending download request (default: 0)
311338
--botNameMatch Block downloads if the bot's name does not match the request
339+
--queue Regex to detect when a bot moves your request into a queue
312340
--save-profile [string] Save current options as a profile
313341
--delete-profile [string] Delete profile
314342
--set-profile [string] Set profile as default
@@ -323,7 +351,7 @@ Alternatively, if you want to pipe the file just ommit the `--path` option :
323351
```bash
324352
xdccJS --host irc.server.net --bot "XDCC-BOT|RED" --download 110 | vlc -
325353
```
326-
**I recommend using double quotes between the `bot name` and `download path`** as they often both include unescaped characeters or whitespaces
354+
**I recommend using double quotation marks between the `bot name` and `download path`** as they often both include unescaped characeters or whitespaces, **They are mandatory when using between `--queue`'s regex** (_see [examples below](#fyi)_)
327355
## Profiles
328356
You can use profiles to automatically load predefined options on startup
329357
### How to use profiles
@@ -387,6 +415,12 @@ xdccJS --delete-profile "my_profile"
387415
# fixed
388416
--path "/home/user/my folder" --bot "XDCC|BOT" --download 123-125
389417
```
418+
- an example with `--queue` regex:
419+
- ```bash
420+
xdccJS --host "irc.server.com" --bot "SOME_BOT" --download "1-100" --queue "/download(.*)\d+\sout\sof\s\d+\/gi"
421+
# excepted bot queue message: "Your request has been queued: position x/x"
422+
```
423+
- see [why is queue important](#download-queue-detection) and [w3schools JavaScript RegExp Reference](https://www.w3schools.com/jsref/jsref_obj_regexp.asp) if you're clueless about regexes
390424

391425
## Documentation
392426
Full documentation is available <a href="https://jipaix.github.io/xdccJS/classes/default.html">here</a>

docs/classes/Job.html

+3-3
Large diffs are not rendered by default.

docs/classes/default.html

+3-3
Large diffs are not rendered by default.

docs/index.html

+14-14
Large diffs are not rendered by default.

docs/interfaces/Candidate.html

+8-8
Large diffs are not rendered by default.

docs/interfaces/Params.html

+14-14
Large diffs are not rendered by default.

package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "xdccjs",
3-
"version": "4.5.0",
3+
"version": "4.5.7",
44
"description": "download files from XDCC bots on IRC, complete implementation of the XDCC protocol",
55
"engines": {
66
"node": ">=14.0.0"
@@ -52,9 +52,9 @@
5252
"@types/chai": "^4.3.1",
5353
"@types/lodash": "^4.14.182",
5454
"@types/mocha": "^9.1.1",
55-
"@types/node": "^17.0.40",
56-
"@typescript-eslint/eslint-plugin": "^5.27.0",
57-
"@typescript-eslint/parser": "^5.27.0",
55+
"@types/node": "^17.0.41",
56+
"@typescript-eslint/eslint-plugin": "^5.27.1",
57+
"@typescript-eslint/parser": "^5.27.1",
5858
"chai": "^4.3.6",
5959
"discord.js": "^13.7.0",
6060
"dotenv": "^16.0.1",

src/ctcp_parser.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ export type ParamsCTCP = ParamsTimeout & {
4141
* // with botNameMatch = true
4242
* xdccJS.download('BOT-A', 1)
4343
* //=> Only accept files comming from 'BOT-A'
44-
* ```js
45-
*
44+
* ```
4645
*/
4746
botNameMatch?: boolean
4847
}

0 commit comments

Comments
 (0)