{"id":16834696,"url":"https://github.com/mscdex/node-nntp","last_synced_at":"2025-03-17T04:32:39.775Z","repository":{"id":65289901,"uuid":"1601659","full_name":"mscdex/node-nntp","owner":"mscdex","description":"An NNTP client module for node.js","archived":false,"fork":false,"pushed_at":"2020-06-21T17:29:04.000Z","size":309,"stargazers_count":74,"open_issues_count":4,"forks_count":27,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-10-19T14:10:48.568Z","etag":null,"topics":[],"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/mscdex.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}},"created_at":"2011-04-11T23:27:08.000Z","updated_at":"2024-01-06T14:26:10.000Z","dependencies_parsed_at":"2023-01-16T15:01:44.297Z","dependency_job_id":null,"html_url":"https://github.com/mscdex/node-nntp","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mscdex%2Fnode-nntp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mscdex%2Fnode-nntp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mscdex%2Fnode-nntp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mscdex%2Fnode-nntp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mscdex","download_url":"https://codeload.github.com/mscdex/node-nntp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221672017,"owners_count":16861348,"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","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":[],"created_at":"2024-10-13T12:07:25.757Z","updated_at":"2024-10-27T11:57:56.129Z","avatar_url":"https://github.com/mscdex.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"Description\n===========\n\nnode-nntp is an NNTP (usenet/newsgroups) client module for [node.js](http://nodejs.org/).\n\n\nRequirements\n============\n\n* [node.js](http://nodejs.org/) -- v0.8.0 or newer\n\n\nExamples\n========\n\n* Get the headers and body of the first message in 'misc.test'\n\n```javascript\n    var NNTP = require('nntp'),\n        inspect = require('util').inspect;\n\n    var c = new NNTP();\n    c.on('ready', function() {\n      c.group('misc.test', function(err, count, low, high) {\n        if (err) throw err;\n      });\n      c.article(function(err, n, id, headers, body) {\n        if (err) throw err;\n        console.log('Article #' + n);\n        console.log('Article ID: ' + id);\n        console.log('Article headers: ' + inspect(headers));\n        console.log('Article body: ' + inspect(body.toString()));\n      });\n    });\n    c.on('error', function(err) {\n      console.log('Error: ' + err);\n    });\n    c.on('close', function(had_err) {\n      console.log('Connection closed');\n    });\n    c.connect({\n      host: 'example.org',\n      user: 'foo',\n      password: 'bar'\n    });\n```\n\n* Get a list of all newsgroups beginning with 'alt.binaries.'\n\n```javascript\n    var NNTP = require('nntp'),\n        inspect = require('util').inspect;\n\n    var c = new NNTP();\n    c.on('ready', function() {\n      c.groups('alt.binaries.*', function(err, list) {\n        if (err) throw err;\n        console.dir(list);\n      });\n    });\n    c.on('error', function(err) {\n      console.log('Error: ' + err);\n    });\n    c.on('close', function(had_err) {\n      console.log('Connection closed');\n    });\n    c.connect({\n      host: 'example.org',\n      user: 'foo',\n      password: 'bar'\n    });\n```\n\n* Post a message to alt.test:\n\n```javascript\n    var NNTP = require('nntp'),\n        inspect = require('util').inspect;\n\n    var c = new NNTP();\n    c.on('ready', function() {\n      var msg = {\n        from: { name: 'Node User', email: 'user@example.com' },\n        groups: 'alt.test',\n        subject: 'Just testing, do not mind me',\n        body: 'node.js rules!'\n      };\n      c.post(msg, function(err) {\n        if (err) throw err;\n      });\n    });\n    c.on('error', function(err) {\n      console.log('Error: ' + err);\n    });\n    c.on('close', function(had_err) {\n      console.log('Connection closed');\n    });\n    c.connect({\n      host: 'example.org',\n      user: 'foo',\n      password: 'bar'\n    });\n```\n\n\nAPI\n===\n\nEvents\n------\n\n* **ready**() - Emitted when connection and authentication were successful.\n\n* **close**(\u003c _boolean_ \u003ehadErr) - Emitted when the connection has fully closed.\n\n* **end**() - Emitted when the connection has ended.\n\n* **error**(\u003c _Error_ \u003eerr) - Emitted when an error occurs. In case of protocol-level errors, `err` contains a 'code' property that references the related NNTP response code.\n\n\nMethods\n-------\n\n* **(constructor)**() - Creates and returns a new NNTP client instance.\n\n* **connect**(\u003c _object_ \u003econfig) - _(void)_ - Attempts to connect to a server. Valid `config` properties are:\n\n    * **host** - \u003c _string_ \u003e - Hostname or IP address of the server. **Default:** 'localhost'\n\n    * **port** - \u003c _integer_ \u003e - Port number of the server. **Default:** 119\n\n    * **secure** - \u003c _boolean_ \u003e - Will this be a secure (TLS) connection? **Default:** false\n\n    * **user** - \u003c _string_ \u003e - Username for authentication. **Default:** (none)\n\n    * **password** - \u003c _string_ \u003e - Password for password-based user authentication. **Default:** (none)\n\n    * **connTimeout** - \u003c _integer_ \u003e - Connection timeout in milliseconds. **Default:** 60000\n\n* **end**() - _(void)_ - Ends the connection with the server.\n\n### Mandatory/Common protocol commands\n\n* **dateTime**(\u003c _function_ \u003ecallback) - _(void)_ - Retrieves the server's UTC date and time in YYYYMMDDHHMMSS format. `callback` has 2 parameters: \u003c _Error_ \u003eerr, \u003c _string_ \u003edatetime.\n\n* **stat**([\u003c _string_ \u003ewhich, ]\u003c _function_ \u003ecallback) - _(void)_ - Retrieves the article number and message ID for the current article if `which` is not given or for the article whose number or message ID is `what`. `callback` has 3 parameters: \u003c _Error_ \u003eerr, \u003c _integer_ \u003earticleNum, \u003c _string_ \u003emsgID.\n\n* **group**(\u003c _string_ \u003egroup, \u003c _function_ \u003ecallback) - _(void)_ - Sets the current newsgroup to `group`. `callback` has 4 parameters: \u003c _Error_ \u003eerr, \u003c _integer_ \u003eestimatedArticleCount, \u003c _integer_ \u003efirstArticleNum, \u003c _integer_ \u003elastArticleNum.\n\n* **next**(\u003c _function_ \u003ecallback) - _(void)_ - Attempts to move to the next article in the current newsgroup. `callback` has 3 parameters: \u003c _Error_ \u003eerr, \u003c _integer_ \u003earticleNum, \u003c _string_ \u003emsgID.\n\n* **prev**(\u003c _function_ \u003ecallback) - _(void)_ - Attempts to move to the previous article in the current newsgroup. `callback` has 3 parameters: \u003c _Error_ \u003eerr, \u003c _integer_ \u003earticleNum, \u003c _string_ \u003emsgID.\n\n* **headers**([\u003c _string_ \u003ewhich, ]\u003c _function_ \u003ecallback) - _(void)_ - Retrieves the headers of the current article if `which` is not given or for the article whose number or message ID is `what`. `callback` has 4 parameters: \u003c _Error_ \u003eerr, \u003c _integer_ \u003earticleNum, \u003c _string_ \u003emsgID, \u003c _object_ \u003eheaders. `headers` values are always arrays (of strings).\n\n* **body**([\u003c _string_ \u003ewhich, ]\u003c _function_ \u003ecallback) - _(void)_ - Retrieves the body of the current article if `which` is not given or for the article whose number or message ID is `what`. `callback` has 4 parameters: \u003c _Error_ \u003eerr, \u003c _integer_ \u003earticleNum, \u003c _string_ \u003emsgID, \u003c _Buffer_ \u003ebody.\n\n* **article**([\u003c _string_ \u003ewhich, ]\u003c _function_ \u003ecallback) - _(void)_ - Retrieves the headers and body of the current article if `which` is not given or for the article whose number or message ID is `what`. `callback` has 5 parameters: \u003c _Error_ \u003eerr, \u003c _integer_ \u003earticleNum, \u003c _string_ \u003emsgID, \u003c _object_ \u003eheaders, \u003c _Buffer_ \u003ebody. `headers` values are always arrays (of strings).\n\n### Extended protocol commands -- these _may not_ be implemented or enabled on all servers\n\n**\\* Note: A `filter` parameter is a single (or Array of) wildcard-capable newsgroup name filter string(s) ([information on the wildcard format](http://tools.ietf.org/html/rfc3977#section-4.2) and [wildcard examples](http://tools.ietf.org/html/rfc3977#section-4.4)).**\n\n* **newNews**(\u003c _mixed_ \u003efilter, \u003c _mixed_ \u003edate, [\u003c _string_ \u003etime, ] \u003c _function_ \u003ecallback) - _(void)_ - Retrieves the message ID of articles in group(s) matching `filter` on or after a date. This date can be specified with `date` being a Date object, or `date` being a 'YYYYMMDD'-formatted string and `time` being a 'HHMMSS'-formatted string (defaults to midnight) in UTC/GMT. `callback` has 2 parameters: \u003c _Error_ \u003eerr, \u003c _array_ \u003emsgIDs.\n\n* **groups**(\u003c _mixed_ \u003efilter, \u003c _function_ \u003ecallback) - _(void)_ - Retrieves a list of groups matching `filter`. `callback` has 2 parameters: \u003c _Error_ \u003eerr, \u003c _array_ \u003egroupsInfo. `groupsInfo` is an array of `[groupName, firstArticleNum, lastArticleNum, status]` rows. Valid statuses are documented [here](http://tools.ietf.org/html/rfc6048#section-3.1).\n\n* **groupsDesc**(\u003c _mixed_ \u003efilter, \u003c _function_ \u003ecallback) - _(void)_ - Retrieves a list of group descriptions matching `filter`. `callback` has 2 parameters: \u003c _Error_ \u003eerr, \u003c _array_ \u003egroups. `groups` is an array of `[groupName, groupDesc]` rows.\n\n* **post**(\u003c _object_ \u003emsg, \u003c _function_ \u003ecallback) - _(void)_ - Posts the given `msg` (as defined below) to the current newsgroup. `callback` has 1 parameter: \u003c _Error_ \u003eerr.\n\n    * **from** - \u003c _object_ \u003e - Who the message is from.\n    \n        * **name** - \u003c _string_ \u003e - Example: 'User'.\n        \n        * **email** - \u003c _string_ \u003e - Example: 'user@example.com'.\n\n    * **groups** - \u003c _mixed_ \u003e - A single newsgroup or array of newsgroups to post this message to.\n\n    * **subject** - \u003c _string_ \u003e - The subject line.\n\n    * **body** - \u003c _mixed_ \u003e - The body content -- a string or a Buffer (will be converted to UTF-8 string).\n\n    * **references** - \u003c _string_ \u003e - Optional string containing the message ids of referenced posts.\n\n\n\n* For methods that return first and last article numbers, the RFC says a group is empty if one of the following is true:\n\n    * The last article number will be one less than the first article number, and\n      the estimated article count will be zero. This is the only time that the\n      last article number can be less than the first article number.\n\n    * First and last article numbers (and estimated article count where applicable) are all 0.\n\n    * The last article number is equal to the first article number. The\n      estimated article count might be zero or non-zero.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmscdex%2Fnode-nntp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmscdex%2Fnode-nntp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmscdex%2Fnode-nntp/lists"}