@xalbex/telegram-bot
Version:
Telegram Bot API for Node.js
73 lines (72 loc) • 3 kB
TypeScript
/// <reference types="node" />
import * as API from './api';
import { EventEmitter } from 'events';
export declare interface TelegramBotManager {
on(event: 'error', listener: (p: Error | string) => void): this;
on(event: 'message', listener: (p: API.Message) => void): this;
on(event: 'edited_message', listener: (p: API.Message) => void): this;
on(event: 'channel_post', listener: (p: API.Message) => void): this;
on(event: 'edited_channel_post', listener: (p: API.Message) => void): this;
on(event: 'inline_query', listener: (p: API.InlineQuery) => void): this;
on(event: 'chosen_inline_result', listener: (p: API.ChosenInlineResult) => void): this;
on(event: 'callback_query', listener: (p: API.CallbackQuery) => void): this;
on(event: 'shipping_query', listener: (p: API.ShippingQuery) => void): this;
on(event: 'pre_checkout_query', listener: (p: API.PreCheckoutQuery) => void): this;
}
export declare class TelegramBotManager extends EventEmitter {
/**
* The object to make raw requests
*/
readonly api: API.TelegramBotRaw;
/**
* When this flag is true, when this object recives an update,
* immediately re-send another getUpdates request for next updates.
*/
private continueUpdates;
/**
* Last update_id received. Update identifiers
* start from a certain positive number and increase sequentially.
* This ID becomes especially handy if you’re using Webhooks,
* since it allows you to ignore repeated updates or to restore
* the correct update sequence, should they get out of order.
* If there are no new updates for at least a week, then identifier
* of the next update will be chosen randomly instead of sequentially.
*/
private lastUpdateId;
/**
* Callback for every chat
*/
private chats;
unknownChat: Chat;
constructor(token: string);
/**
* Put this object into listening state.
* The object will emit events for each new update.
*/
start(): void;
/**
* Stop this object form the listening state.
* After the response of the getUpdates request it
* will not make any other requests. *
*/
stop(): void;
/**
* Continue to make getUpdates requests and
* emit the appropriate event until the flag continueUpdates is true.
*/
private dispatchUpdates;
/**
* Continue to make getUpdates requests and
* emit the appropriate event until the flag continueUpdates is true.
*/
private old;
}
export interface Chat {
onMessage?(message: API.Message): Promise<any>;
onEditedMessage?(message: API.Message): Promise<any>;
onChannelPost?(message: API.Message): Promise<any>;
onEditedChannelPost?(message: API.Message): Promise<any>;
onCallbackQuery?(message: API.CallbackQuery): Promise<any>;
onShippingQuery?(message: API.ShippingQuery): Promise<any>;
onPreCheckoutQuery?(message: API.PreCheckoutQuery): Promise<any>;
}