import { IGroupResponse, INodeCountTree, IXoverArticles } from './interfaces'; import { MessageTreeNode } from './tree/MessageTreeNode'; import { IMessageInfo } from './interfaces'; import Response from './utils/response'; import { ConstructorProps, PostType } from './types'; export default class NNTP { private socket; private readonly host; private readonly port; private encoding?; private postingAllowed; private isConnected; private connectionInformation; constructor(options: ConstructorProps); connect(): Promise; /** * Returns the welcome message sent by the server in reply to initial connection * It may contain disclaimers or help information that may be relevant for the user * * @returns {string} */ getWelcome(): string | undefined; /** * Get group information by group name * On success returns status 211 * On error returns status 411 * https://tools.ietf.org/html/rfc3977#section-6.1.1 * * @param {string} group * @returns {Promise} */ getGroup(group: string): Promise; /** * Get list of articles numberIDs in current group * On success returns status 211 * On error returns status 411 * https://tools.ietf.org/html/rfc3977#section-6.1.2 * * @param {string} group * @returns {Promise} */ listGroupArticles(group: string): Promise; /** * Returns MIME formatted ARTICLE body * On success returns status 220 * On error returns status 430 * https://tools.ietf.org/html/rfc3977#section-6.2.1 * * @param {string} messageID */ getArticleBody(messageID: string): Promise<{ html: string; raw: string; attachments: any; }>; /** * Behaviour is identical to the ARTICLE command, expect only headers are present * On success returns status 221 * On error returns status 430 * https://tools.ietf.org/html/rfc3977#section-6.2.2 * * @param {string} messageID * @returns {Promise} */ getArticleHead(messageID: string): Promise; /** * Get next article in given group, note that group must be selected beforehand * On success returns status 223 * On error returns 421 * https://tools.ietf.org/html/rfc3977#section-6.1.4 * * @returns {Promise} */ nextArticle(): Promise; /** * Get previous article in given group, note that group must be selected beforehand * On success returns status 223 * On error returns status 422 * https://tools.ietf.org/html/rfc3977#section-6.1.3 * * @returns {Promise} */ prevArticle(): Promise; /** * Post an article with given parameters, if no reference is present then article will be his own thread * On success return status 340 on firstPhase and 240 on secondPhase * On error returns status 440 on firstPhase or 441 on secondPhase * https://tools.ietf.org/html/rfc3977#section-6.3.1 * * @returns {Promise} * @param request */ postArticle(request: PostType): Promise; /** * Returns an array of all available groups in newsgroup * On success return status 215 * On error returns empty array * https://tools.ietf.org/html/rfc3977#section-7.6 * * @returns {Promise} */ listGroups(): Promise; /** * Returns the format of articles on server * On success returns status 215 * On error returns empty response * https://tools.ietf.org/html/rfc3977#section-8.4 * * @returns {Promise} */ overview(): Promise; /** * Returns information from the overview database for the specified range of articles * Note that before this command one must select group and have Format of articles using LIST OVERVIEW.FMT * On success returns 224 * On error returns 412, 420 or 502 * https://tools.ietf.org/html/rfc2980#section-2.8 * * @param {number} from * @param {number} to * @param {Array} format * @returns {Promise} */ xover(from: number, to: number, format: string[]): Promise; /** * Returns the contents of all the fields in database for the specified range of articles * This method returns tree representation of articles using MessageTreeNode class * On success returns 224 * On error returns 412 when no group is selected and 423 when there are no articles in given range * https://tools.ietf.org/html/rfc3977#section-8.3 * * @return {Promise} * @param from * @param to */ overRange(from: number | string, to: number | string): Promise; /** * Returns the contents of all the fields in database for the specified range of articles * This method returns tree representation of articles using MessageTreeNode class * Note that MessageTreeNode is filtered using regular expression * On success returns 224 * On error returns 412 when no group is selected and 423 when there are no articles in given range * https://tools.ietf.org/html/rfc3977#section-8.3 * * @return {Promise} * @param from * @param to * @param begin * @param end * @param pattern */ overRangeRegex(from: number, to: number, begin: number, end: number, pattern: string): Promise; /** * Returns the contents of all the fields in database for the specified range of articles * This method returns tree representation of articles using MessageTreeNode class * Note that MessageTreeNode is filtered using regular globalID of article * On success returns 224 * On error returns 412 when no group is selected and 423 when there are no articles in given range * https://tools.ietf.org/html/rfc3977#section-8.3 * * @return {Promise} * @param from * @param to * @param pattern */ overRangeReference(from: number, to: number, pattern: string): Promise; /** * Returns an array of message-ids of articles posted or received on the server * uses dateTime wildmat and group pattern `server.*` * dateTime wildmat in format `YYYYMMDD` for date and `HHMMSS` for time * On success returns 230 * https://tools.ietf.org/html/rfc3977#section-7.4 * * @return {Promise} * @param wildmat * @param dateTime */ newNews(wildmat: string, dateTime: string): Promise; /** * Returns whether an article exists on sever, boolean value is always returned * On success returns 223 * hhttps://tools.ietf.org/html/rfc3977#section-6.2.4 * * @return {Promise} * @param messageID */ checkExistence(messageID: string): Promise; /** * Returns an array of newsgroups created on the server since the wildmat dateTime * wildmat in format `YYYYMMDD` for date and `HHMMSS` for time * On success returns 231 * https://tools.ietf.org/html/rfc3977#section-7.3 * * @return {Promise} * @param dateTime */ newGroups(dateTime: string): Promise; /** * Disconnect from the server * On success returns 205 * https://tools.ietf.org/html/rfc3977#section-5.4 * * @returns {Promise} */ quit(): Promise; /** * Getting response from server * * @returns Promise */ private getResponse; }