@aracna/telegram-bot 1.9.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +18 -0
  3. package/builders/button.builder.js +31 -0
  4. package/childs/add.js +10 -0
  5. package/childs/answer.js +19 -0
  6. package/childs/ban.js +10 -0
  7. package/childs/create.js +17 -0
  8. package/childs/delete.js +19 -0
  9. package/childs/download.js +32 -0
  10. package/childs/edit.js +22 -0
  11. package/childs/export.js +10 -0
  12. package/childs/forward.js +15 -0
  13. package/childs/get.js +37 -0
  14. package/childs/leave.js +10 -0
  15. package/childs/pin.js +10 -0
  16. package/childs/polling.js +34 -0
  17. package/childs/privates/send.private.js +19 -0
  18. package/childs/promote.js +10 -0
  19. package/childs/restrict.js +15 -0
  20. package/childs/send.js +130 -0
  21. package/childs/set.js +44 -0
  22. package/childs/stop.js +13 -0
  23. package/childs/unban.js +10 -0
  24. package/childs/unpin.js +10 -0
  25. package/childs/upload.js +10 -0
  26. package/childs/webhook.js +22 -0
  27. package/declarations/builders/button.builder.d.ts +11 -0
  28. package/declarations/childs/add.d.ts +6 -0
  29. package/declarations/childs/answer.d.ts +9 -0
  30. package/declarations/childs/ban.d.ts +6 -0
  31. package/declarations/childs/create.d.ts +6 -0
  32. package/declarations/childs/delete.d.ts +8 -0
  33. package/declarations/childs/download.d.ts +9 -0
  34. package/declarations/childs/edit.d.ts +10 -0
  35. package/declarations/childs/export.d.ts +5 -0
  36. package/declarations/childs/forward.d.ts +6 -0
  37. package/declarations/childs/get.d.ts +15 -0
  38. package/declarations/childs/leave.d.ts +5 -0
  39. package/declarations/childs/pin.d.ts +6 -0
  40. package/declarations/childs/polling.d.ts +9 -0
  41. package/declarations/childs/privates/send.private.d.ts +7 -0
  42. package/declarations/childs/promote.d.ts +6 -0
  43. package/declarations/childs/restrict.d.ts +6 -0
  44. package/declarations/childs/send.d.ts +31 -0
  45. package/declarations/childs/set.d.ts +17 -0
  46. package/declarations/childs/stop.d.ts +7 -0
  47. package/declarations/childs/unban.d.ts +5 -0
  48. package/declarations/childs/unpin.d.ts +5 -0
  49. package/declarations/childs/upload.d.ts +7 -0
  50. package/declarations/childs/webhook.d.ts +8 -0
  51. package/declarations/definitions/constants.d.ts +2 -0
  52. package/declarations/definitions/enums.d.ts +22 -0
  53. package/declarations/definitions/interfaces.d.ts +97 -0
  54. package/declarations/definitions/types.d.ts +4 -0
  55. package/declarations/index.d.ts +12 -0
  56. package/declarations/loggers/module.logger.d.ts +2 -0
  57. package/declarations/modules/api.d.ts +5 -0
  58. package/declarations/modules/builder.d.ts +4 -0
  59. package/declarations/modules/child.d.ts +5 -0
  60. package/declarations/modules/configuration.d.ts +8 -0
  61. package/declarations/modules/dummy.d.ts +9 -0
  62. package/declarations/modules/telegram.d.ts +87 -0
  63. package/declarations/utils/callback.query.utils.d.ts +5 -0
  64. package/declarations/utils/command.utils.d.ts +8 -0
  65. package/declarations/utils/context.utils.d.ts +13 -0
  66. package/declarations/utils/html.utils.d.ts +5 -0
  67. package/declarations/utils/inline.keyboard.utils.d.ts +4 -0
  68. package/declarations/utils/reply.to.message.utils.d.ts +6 -0
  69. package/declarations/utils/start.utils.d.ts +7 -0
  70. package/definitions/constants.js +11 -0
  71. package/definitions/enums.js +27 -0
  72. package/definitions/interfaces.js +3 -0
  73. package/definitions/types.js +2 -0
  74. package/index.d.ts +498 -0
  75. package/index.js +24 -0
  76. package/loggers/module.logger.js +6 -0
  77. package/modules/api.js +26 -0
  78. package/modules/builder.js +8 -0
  79. package/modules/child.js +10 -0
  80. package/modules/configuration.js +10 -0
  81. package/modules/dummy.js +56 -0
  82. package/modules/telegram.js +353 -0
  83. package/package.json +28 -0
  84. package/utils/callback.query.utils.js +26 -0
  85. package/utils/command.utils.js +29 -0
  86. package/utils/context.utils.js +43 -0
  87. package/utils/html.utils.js +20 -0
  88. package/utils/inline.keyboard.utils.js +26 -0
  89. package/utils/reply.to.message.utils.js +27 -0
  90. package/utils/start.utils.js +32 -0
@@ -0,0 +1,9 @@
1
+ import { FetchError } from '@aracna/core';
2
+ import { AnswerCallbackQuery, AnswerInlineQuery, AnswerPreCheckoutQuery, AnswerShippingQuery, InlineQueryResult } from '@aracna/telegram-bot-types';
3
+ import { Child } from '../modules/child';
4
+ export declare class Answer extends Child {
5
+ callbackQuery(id: string, parameters?: Partial<AnswerCallbackQuery>): Promise<boolean | FetchError>;
6
+ inlineQuery(id: string, results: InlineQueryResult[], parameters?: Partial<AnswerInlineQuery>): Promise<boolean | FetchError>;
7
+ preCheckoutQuery(id: string, ok: boolean, parameters?: Partial<AnswerPreCheckoutQuery>): Promise<boolean | FetchError>;
8
+ shippingQuery(id: string, ok: boolean, parameters?: Partial<AnswerShippingQuery>): Promise<boolean | FetchError>;
9
+ }
@@ -0,0 +1,6 @@
1
+ import { FetchError } from '@aracna/core';
2
+ import { BanChatMember } from '@aracna/telegram-bot-types';
3
+ import { Child } from '../modules/child';
4
+ export declare class Ban extends Child {
5
+ chatMember(chatID: number, userID: number, parameters?: Partial<BanChatMember>): Promise<boolean | FetchError>;
6
+ }
@@ -0,0 +1,6 @@
1
+ import { FetchError } from '@aracna/core';
2
+ import { CreateNewStickerSet, InputSticker } from '@aracna/telegram-bot-types';
3
+ import { Child } from '../modules/child';
4
+ export declare class Create extends Child {
5
+ stickerSet(userID: number, format: string, name: string, title: string, stickers: InputSticker[], parameters: Partial<CreateNewStickerSet>): Promise<boolean | FetchError>;
6
+ }
@@ -0,0 +1,8 @@
1
+ import { FetchError } from '@aracna/core';
2
+ import { Child } from '../modules/child';
3
+ export declare class Delete extends Child {
4
+ chatPhoto(chatID: number): Promise<boolean | FetchError>;
5
+ chatStickerSet(chatID: number): Promise<boolean | FetchError>;
6
+ message(chatID: number, message: number): Promise<boolean | FetchError>;
7
+ stickerFromSet(sticker: string): Promise<boolean | FetchError>;
8
+ }
@@ -0,0 +1,9 @@
1
+ /// <reference types="node" />
2
+ import { FetchError } from '@aracna/core';
3
+ import { API } from '../modules/api';
4
+ import { Child } from '../modules/child';
5
+ export declare class Download extends Child {
6
+ api: API;
7
+ file(id: string): Promise<Buffer | FetchError>;
8
+ userFirstProfilePhoto(id: number): Promise<Buffer | FetchError | Error>;
9
+ }
@@ -0,0 +1,10 @@
1
+ import { FetchError } from '@aracna/core';
2
+ import { EditMessageCaption, EditMessageLiveLocation, EditMessageMedia, EditMessageReplyMarkup, EditMessageText, InputMedia, Message } from '@aracna/telegram-bot-types';
3
+ import { Child } from '../modules/child';
4
+ export declare class Edit extends Child {
5
+ messageCaption(parameters: EditMessageCaption): Promise<Message | FetchError>;
6
+ messageLiveLocation(latitude: number, longitude: number, parameters: Partial<EditMessageLiveLocation>): Promise<Message | FetchError>;
7
+ messageMedia(media: InputMedia, parameters: Partial<EditMessageMedia>): Promise<Message | FetchError>;
8
+ messageReplyMarkup(parameters: EditMessageReplyMarkup): Promise<Message | FetchError>;
9
+ messageText(text: string, parameters: Partial<EditMessageText>): Promise<Message | FetchError>;
10
+ }
@@ -0,0 +1,5 @@
1
+ import { FetchError } from '@aracna/core';
2
+ import { Child } from '../modules/child';
3
+ export declare class Export extends Child {
4
+ chatInviteLink(chatID: number): Promise<string | FetchError>;
5
+ }
@@ -0,0 +1,6 @@
1
+ import { FetchError } from '@aracna/core';
2
+ import { ForwardMessage, Message } from '@aracna/telegram-bot-types';
3
+ import { Child } from '../modules/child';
4
+ export declare class Forward extends Child {
5
+ message(chatID: number, fromChatID: number, messageID: number, parameters?: Partial<ForwardMessage>): Promise<Message | FetchError>;
6
+ }
@@ -0,0 +1,15 @@
1
+ import { FetchError } from '@aracna/core';
2
+ import { BotCommand, Chat, ChatMember, File, GameHighScore, GetGameHighScores, GetUserProfilePhotos, StickerSet, User, UserProfilePhotos } from '@aracna/telegram-bot-types';
3
+ import { Child } from '../modules/child';
4
+ export declare class Get extends Child {
5
+ chat(id: number): Promise<Chat | FetchError>;
6
+ chatAdministrators(id: number): Promise<ChatMember[] | FetchError>;
7
+ chatMember(chatID: number, userID: number): Promise<ChatMember | FetchError>;
8
+ chatMemberCount(id: number): Promise<number | FetchError>;
9
+ commands(): Promise<BotCommand[] | FetchError>;
10
+ file(id: string): Promise<File | FetchError>;
11
+ gameHighScores(userID: number, parameters?: Partial<GetGameHighScores>): Promise<GameHighScore | FetchError>;
12
+ me(): Promise<User | FetchError>;
13
+ stickerSet(name: string): Promise<StickerSet | FetchError>;
14
+ userProfilePhotos(id: number, parameters?: Partial<GetUserProfilePhotos>): Promise<UserProfilePhotos | FetchError>;
15
+ }
@@ -0,0 +1,5 @@
1
+ import { FetchError } from '@aracna/core';
2
+ import { Child } from '../modules/child';
3
+ export declare class Leave extends Child {
4
+ chat(id: number): Promise<boolean | FetchError>;
5
+ }
@@ -0,0 +1,6 @@
1
+ import { FetchError } from '@aracna/core';
2
+ import { PinChatMessage } from '@aracna/telegram-bot-types';
3
+ import { Child } from '../modules/child';
4
+ export declare class Pin extends Child {
5
+ chatMessage(chatID: number, message: number, parameters?: Partial<PinChatMessage>): Promise<boolean | FetchError>;
6
+ }
@@ -0,0 +1,9 @@
1
+ import { GetUpdates } from '@aracna/telegram-bot-types';
2
+ import { Child } from '../modules/child';
3
+ export declare class Polling extends Child {
4
+ active: boolean;
5
+ offset: number;
6
+ start(ms: number | undefined, parameters: Partial<GetUpdates>): void;
7
+ stop(): void;
8
+ private get;
9
+ }
@@ -0,0 +1,7 @@
1
+ import { FetchError } from '@aracna/core';
2
+ import { InlineKeyboardButton, Message, SendMessage } from '@aracna/telegram-bot-types';
3
+ import { Child } from '../../modules/child';
4
+ export declare class SendPrivate extends Child {
5
+ buttons(chatIDs: [number, number], text: string, buttons: InlineKeyboardButton[], parameters?: Partial<SendMessage>): Promise<Message | FetchError | Error>;
6
+ repliable<T>(chatIDs: [number, number], text: string, data: T, type: string, parameters?: Partial<SendMessage>): Promise<Message | FetchError | Error>;
7
+ }
@@ -0,0 +1,6 @@
1
+ import { FetchError } from '@aracna/core';
2
+ import { PromoteChatMember } from '@aracna/telegram-bot-types';
3
+ import { Child } from '../modules/child';
4
+ export declare class Promote extends Child {
5
+ chatMember(chatID: number, userID: number, parameters?: Partial<PromoteChatMember>): Promise<boolean | FetchError>;
6
+ }
@@ -0,0 +1,6 @@
1
+ import { FetchError } from '@aracna/core';
2
+ import { ChatPermissions, RestrictChatMember } from '@aracna/telegram-bot-types';
3
+ import { Child } from '../modules/child';
4
+ export declare class Restrict extends Child {
5
+ chatMember(chatID: number, userID: number, permissions: ChatPermissions, parameters?: Partial<RestrictChatMember>): Promise<boolean | FetchError>;
6
+ }
@@ -0,0 +1,31 @@
1
+ import { FetchError } from '@aracna/core';
2
+ import { InlineKeyboardButton, LabeledPrice, Message, SendAnimation, SendAudio, SendContact, SendDice, SendDocument, SendGame, SendInvoice, SendLocation, SendMediaGroup, SendMessage, SendPhoto, SendPoll, SendSticker, SendVenue, SendVideo, SendVideoNote, SendVoice } from '@aracna/telegram-bot-types';
3
+ import { InputMediaAlternative } from '../definitions/interfaces';
4
+ import { InputFile } from '../definitions/types';
5
+ import { Child } from '../modules/child';
6
+ import { SendPrivate } from './privates/send.private';
7
+ export declare class Send extends Child {
8
+ private: SendPrivate;
9
+ animation(chatID: number, file: InputFile, parameters?: Partial<SendAnimation>): Promise<Message | FetchError>;
10
+ audio(chatID: number, file: InputFile, parameters?: Partial<SendAudio>): Promise<Message | FetchError>;
11
+ document(chatID: number, file: InputFile, parameters?: Partial<SendDocument>): Promise<Message | FetchError>;
12
+ buttons(chatID: number, text: string, buttons: InlineKeyboardButton[], parameters?: Partial<SendMessage>): Promise<Message | FetchError | Error>;
13
+ chatAction(chatID: number, action: string): Promise<boolean | FetchError>;
14
+ contact(chatID: number, phoneNumber: string, firstName: string, parameters?: Partial<SendContact>): Promise<Message | FetchError>;
15
+ dice(chatID: number, parameters?: Partial<SendDice>): Promise<Message | FetchError>;
16
+ game(chatID: number, gameShortName: string, parameters?: Partial<SendGame>): Promise<Message | FetchError>;
17
+ html(chatID: number, text: string, parameters?: Partial<SendMessage>): Promise<Message | FetchError>;
18
+ invoice(chatID: number, title: string, description: string, payload: string, providerToken: string, startParameter: string, currency: string, prices: LabeledPrice[], parameters?: Partial<SendInvoice>): Promise<Message | FetchError>;
19
+ location(chatID: number, latitude: number, longitude: number, parameters?: Partial<SendLocation>): Promise<Message | FetchError>;
20
+ mediaGroup(chatID: number, media: InputMediaAlternative[], parameters?: Partial<SendMediaGroup>): Promise<Message | FetchError>;
21
+ message(chatID: number, text: string, parameters?: Partial<SendMessage>): Promise<Message | FetchError>;
22
+ photo(chatID: number, file: InputFile, parameters?: Partial<SendPhoto>): Promise<Message | FetchError>;
23
+ poll(chatID: number, question: string, options: string[], parameters?: Partial<SendPoll>): Promise<Message | FetchError>;
24
+ repliable<T>(chatID: number, text: string, data: T, type: string, parameters?: Partial<SendMessage>, fromChatID?: number): Promise<Message | FetchError>;
25
+ sticker(chatID: number, file: InputFile, parameters?: Partial<SendSticker>): Promise<Message | FetchError>;
26
+ venue(chatID: number, latitude: number, longitude: number, title: string, address: string, parameters?: Partial<SendVenue>): Promise<Message | FetchError>;
27
+ video(chatID: number, file: InputFile, parameters?: Partial<SendVideo>): Promise<Message | FetchError>;
28
+ videoNote(chatID: number, file: InputFile, parameters?: Partial<SendVideoNote>): Promise<Message | FetchError>;
29
+ voice(chatID: number, file: InputFile, parameters?: Partial<SendVoice>): Promise<Message | FetchError>;
30
+ private file;
31
+ }
@@ -0,0 +1,17 @@
1
+ import { FetchError } from '@aracna/core';
2
+ import { BotCommand, ChatPermissions, PassportElementError, SetGameScore, SetMyCommands, SetStickerSetThumbnail } from '@aracna/telegram-bot-types';
3
+ import { InputFile } from '../definitions/types';
4
+ import { Child } from '../modules/child';
5
+ export declare class Set extends Child {
6
+ chatAdministratorCustomTitle(chatID: number, userID: number, customTitle: string): Promise<boolean | FetchError>;
7
+ chatDescription(chatID: number, description: string): Promise<boolean | FetchError>;
8
+ chatPermissions(chatID: number, permissions: ChatPermissions): Promise<boolean | FetchError>;
9
+ chatPhoto(chatID: number, photo: InputFile): Promise<boolean | FetchError>;
10
+ chatStickerSet(chatID: number, stickerSetName: string): Promise<boolean | FetchError>;
11
+ chatTitle(chatID: number, title: string): Promise<boolean | FetchError>;
12
+ commands(commands: BotCommand[], parameters?: Partial<SetMyCommands>): Promise<boolean | FetchError>;
13
+ gameScore(userID: number, score: number, parameters?: Partial<SetGameScore>): Promise<boolean | FetchError>;
14
+ passportDataErrors(userID: number, errors: PassportElementError[]): Promise<boolean | FetchError>;
15
+ stickerPositionInSet(sticker: string, position: number): Promise<boolean | FetchError>;
16
+ stickerSetThumb(name: string, userID: number, parameters?: Partial<SetStickerSetThumbnail>): Promise<boolean | FetchError>;
17
+ }
@@ -0,0 +1,7 @@
1
+ import { FetchError } from '@aracna/core';
2
+ import { Message, Poll, StopMessageLiveLocation, StopPoll } from '@aracna/telegram-bot-types';
3
+ import { Child } from '../modules/child';
4
+ export declare class Stop extends Child {
5
+ messageLiveLocation(parameters: StopMessageLiveLocation): Promise<Message | boolean | FetchError>;
6
+ poll(chatID: number, message: number, parameters?: Partial<StopPoll>): Promise<Poll | FetchError>;
7
+ }
@@ -0,0 +1,5 @@
1
+ import { FetchError } from '@aracna/core';
2
+ import { Child } from '../modules/child';
3
+ export declare class Unban extends Child {
4
+ chatMember(chatID: number, userID: number): Promise<boolean | FetchError>;
5
+ }
@@ -0,0 +1,5 @@
1
+ import { FetchError } from '@aracna/core';
2
+ import { Child } from '../modules/child';
3
+ export declare class Unpin extends Child {
4
+ chatMessage(chatID: number): Promise<boolean | FetchError>;
5
+ }
@@ -0,0 +1,7 @@
1
+ import { FetchError } from '@aracna/core';
2
+ import { File } from '@aracna/telegram-bot-types';
3
+ import { InputFile } from '../definitions/types';
4
+ import { Child } from '../modules/child';
5
+ export declare class Upload extends Child {
6
+ stickerFile(userID: number, format: string, sticker: InputFile): Promise<File | FetchError>;
7
+ }
@@ -0,0 +1,8 @@
1
+ import { FetchError } from '@aracna/core';
2
+ import { SetWebhook } from '@aracna/telegram-bot-types';
3
+ import { Child } from '../modules/child';
4
+ export declare class Webhook extends Child {
5
+ delete(): Promise<boolean | FetchError>;
6
+ set(route?: string, parameters?: Partial<SetWebhook>): Promise<boolean | FetchError>;
7
+ url(route: string): string;
8
+ }
@@ -0,0 +1,2 @@
1
+ export declare const REGEXP_COMMAND: RegExp;
2
+ export declare const REGEXP_COMMAND_WITH_USERNAME: RegExp;
@@ -0,0 +1,22 @@
1
+ export declare enum LoggerName {
2
+ MODULE = "TELEGRAM_MODULE"
3
+ }
4
+ export declare enum UpdateType {
5
+ CALLBACK_QUERY = "CALLBACK_QUERY",
6
+ CHANNEL_POST = "CHANNEL_POST",
7
+ CHAT_JOIN_REQUEST = "CHAT_JOIN_REQUEST",
8
+ CHAT_MEMBER = "CHAT_MEMBER",
9
+ CHOSEN_INLINE_RESULT = "CHOSEN_INLINE_RESULT",
10
+ DOCUMENT = "DOCUMENT",
11
+ EDITED_CHANNEL_POST = "EDITED_CHANNEL_POST",
12
+ EDITED_MESSAGE = "EDITED_MESSAGE",
13
+ INLINE_QUERY = "INLINE_QUERY",
14
+ MESSAGE = "MESSAGE",
15
+ MY_CHAT_MEMBER = "MY_CHAT_MEMBER",
16
+ POLL = "POLL",
17
+ POLL_ANSWER = "POLL_ANSWER",
18
+ PRE_CHECKOUT_QUERY = "PRE_CHECKOUT_QUERY",
19
+ REPLY_TO_MESSAGE = "REPLY_TO_MESSAGE",
20
+ SHIPPING_QUERY = "SHIPPING_QUERY",
21
+ START = "START"
22
+ }
@@ -0,0 +1,97 @@
1
+ import { FetchResponse } from '@aracna/core';
2
+ import { CallbackQuery as NativeCallbackQuery, ChatJoinRequest, ChatMemberUpdated, ChosenInlineResult, InlineKeyboardButton, InlineQuery, InputMediaAudio, InputMediaDocument, InputMediaPhoto, InputMediaVideo, Message, Poll, PollAnswer, PreCheckoutQuery, SendMediaGroup, ShippingQuery } from '@aracna/telegram-bot-types';
3
+ import { UpdateType } from './enums';
4
+ import { HandlerMiddleware, InputFile } from './types';
5
+ export interface APIResponse<T> extends FetchResponse<APIResponseData<T>> {
6
+ }
7
+ export interface APIResponseData<T> {
8
+ ok: boolean;
9
+ result: T;
10
+ }
11
+ export interface CallbackQuery<T = any> extends NativeCallbackQuery {
12
+ body: CallbackQueryBody<T>;
13
+ }
14
+ export interface CallbackQueryBody<T = any> {
15
+ c?: number;
16
+ d: T;
17
+ t: string;
18
+ }
19
+ export interface ConfigurationAPI {
20
+ post: {
21
+ callback: {
22
+ success: <T, U>(body: T, result: U | Error) => void;
23
+ };
24
+ };
25
+ }
26
+ export interface ConfigurationDefault {
27
+ buttons: {
28
+ text: (chatID: number) => Promise<InlineKeyboardButton[]>;
29
+ url: (chatID: number) => Promise<InlineKeyboardButton[]>;
30
+ login: (chatID: number) => Promise<InlineKeyboardButton[]>;
31
+ callback: (chatID: number) => Promise<InlineKeyboardButton[]>;
32
+ query: (chatID: number) => Promise<InlineKeyboardButton[]>;
33
+ queryCurrentChat: (chatID: number) => Promise<InlineKeyboardButton[]>;
34
+ game: (chatID: number) => Promise<InlineKeyboardButton[]>;
35
+ pay: (chatID: number) => Promise<InlineKeyboardButton[]>;
36
+ };
37
+ }
38
+ export interface ConfigurationHandler {
39
+ send: {
40
+ buttons: {
41
+ empty: (chatID: number) => Error;
42
+ };
43
+ };
44
+ }
45
+ export interface Context {
46
+ [UpdateType.CALLBACK_QUERY]: CallbackQuery;
47
+ [UpdateType.CHANNEL_POST]: Message;
48
+ [UpdateType.CHAT_JOIN_REQUEST]: ChatJoinRequest;
49
+ [UpdateType.CHAT_MEMBER]: ChatMemberUpdated;
50
+ [UpdateType.CHOSEN_INLINE_RESULT]: ChosenInlineResult;
51
+ [UpdateType.DOCUMENT]: Message;
52
+ [UpdateType.EDITED_CHANNEL_POST]: Message;
53
+ [UpdateType.EDITED_MESSAGE]: Message;
54
+ [UpdateType.INLINE_QUERY]: InlineQuery;
55
+ [UpdateType.MESSAGE]: Message;
56
+ [UpdateType.MY_CHAT_MEMBER]: ChatMemberUpdated;
57
+ [UpdateType.POLL]: Poll;
58
+ [UpdateType.POLL_ANSWER]: PollAnswer;
59
+ [UpdateType.PRE_CHECKOUT_QUERY]: PreCheckoutQuery;
60
+ [UpdateType.REPLY_TO_MESSAGE]: ReplyToMessage;
61
+ [UpdateType.SHIPPING_QUERY]: ShippingQuery;
62
+ [UpdateType.START]: Start;
63
+ }
64
+ export interface Handler<T extends UpdateType = any, U extends HandlerOptions = HandlerOptions> {
65
+ description?: string;
66
+ id: string;
67
+ key?: string;
68
+ middleware: HandlerMiddleware<T>;
69
+ options: U;
70
+ type: UpdateType;
71
+ }
72
+ export interface HandlerOptions {
73
+ deleteOnCallbackQuery?: boolean;
74
+ deleteOnReply?: boolean;
75
+ deleteOnMessageStart?: boolean;
76
+ }
77
+ export interface InputMediaAlternative extends Omit<InputMediaAudio | InputMediaDocument | InputMediaPhoto | InputMediaVideo, 'media'> {
78
+ media: InputFile;
79
+ }
80
+ export interface MessageBody<T = any> {
81
+ chatID?: number;
82
+ data: T;
83
+ type: string;
84
+ }
85
+ export interface ReplyToMessage<T = any> extends Message {
86
+ body: MessageBody<T>;
87
+ }
88
+ export interface SendMediaGroupAlternative extends Omit<SendMediaGroup, 'media'> {
89
+ media: InputMediaAlternative[];
90
+ }
91
+ export interface Start<T = any> extends Message {
92
+ body: MessageBody<T>;
93
+ }
94
+ export interface TelegramName {
95
+ first: string;
96
+ last: string;
97
+ }
@@ -0,0 +1,4 @@
1
+ import { UpdateType } from './enums';
2
+ import { Context } from './interfaces';
3
+ export declare type HandlerMiddleware<T extends UpdateType> = (context: Context[T]) => any;
4
+ export declare type InputFile = File | string;
@@ -0,0 +1,12 @@
1
+ export { LoggerName as TelegramLoggerName, UpdateType } from './definitions/enums';
2
+ export { CallbackQuery, CallbackQueryBody, Context, Handler, HandlerOptions, MessageBody, ReplyToMessage, Start } from './definitions/interfaces';
3
+ export { HandlerMiddleware, InputFile } from './definitions/types';
4
+ export { Configuration as TelegramConfiguration } from './modules/configuration';
5
+ export { Telegram } from './modules/telegram';
6
+ export { CallbackQueryUtils } from './utils/callback.query.utils';
7
+ export { CommandUtils } from './utils/command.utils';
8
+ export { ContextUtils } from './utils/context.utils';
9
+ export { HTMLUtils } from './utils/html.utils';
10
+ export { InlineKeyboardUtils } from './utils/inline.keyboard.utils';
11
+ export { ReplyToMessageUtils } from './utils/reply.to.message.utils';
12
+ export { StartUtils } from './utils/start.utils';
@@ -0,0 +1,2 @@
1
+ import { Logger } from '@aracna/core';
2
+ export declare const ModuleLogger: Logger;
@@ -0,0 +1,5 @@
1
+ import { API as CoreAPI, APIConfig, FetchError, RequestMethod } from '@aracna/core';
2
+ export declare class API extends CoreAPI {
3
+ post<V, W, X = undefined>(path: string, body?: W, config?: APIConfig<void>): Promise<V | FetchError<X>>;
4
+ transformBody<V>(method: RequestMethod, path: string, body: V, config: APIConfig<void>): Promise<FormData>;
5
+ }
@@ -0,0 +1,4 @@
1
+ import { ButtonBuilder } from '../builders/button.builder';
2
+ export declare class Builder {
3
+ button: ButtonBuilder;
4
+ }
@@ -0,0 +1,5 @@
1
+ import type { Telegram } from './telegram';
2
+ export declare class Child {
3
+ protected telegram: Telegram;
4
+ constructor(telegram: Telegram);
5
+ }
@@ -0,0 +1,8 @@
1
+ import { ConfigurationAPI, ConfigurationDefault, ConfigurationHandler } from '../definitions/interfaces';
2
+ declare class _ {
3
+ api: ConfigurationAPI;
4
+ default: ConfigurationDefault;
5
+ handler: ConfigurationHandler;
6
+ }
7
+ export declare const Configuration: _;
8
+ export {};
@@ -0,0 +1,9 @@
1
+ import { CallbackQueryBody, ConfigurationAPI, ConfigurationDefault, ConfigurationHandler, Handler, MessageBody } from '../definitions/interfaces';
2
+ export declare class Dummy {
3
+ static get callbackQueryBody(): CallbackQueryBody;
4
+ static get configurationAPI(): ConfigurationAPI;
5
+ static get configurationDefault(): ConfigurationDefault;
6
+ static get configurationHandler(): ConfigurationHandler;
7
+ static get handler(): Handler<any, any>;
8
+ static get messageBody(): MessageBody;
9
+ }
@@ -0,0 +1,87 @@
1
+ import { BotCommand, CallbackQuery, ChatJoinRequest, ChatMemberUpdated, ChosenInlineResult, InlineQuery, Message, Poll, PollAnswer, PreCheckoutQuery, ShippingQuery, Update } from '@aracna/telegram-bot-types';
2
+ import { Add } from '../childs/add';
3
+ import { Answer } from '../childs/answer';
4
+ import { Ban } from '../childs/ban';
5
+ import { Create } from '../childs/create';
6
+ import { Delete } from '../childs/delete';
7
+ import { Download } from '../childs/download';
8
+ import { Edit } from '../childs/edit';
9
+ import { Export } from '../childs/export';
10
+ import { Forward } from '../childs/forward';
11
+ import { Get } from '../childs/get';
12
+ import { Leave } from '../childs/leave';
13
+ import { Pin } from '../childs/pin';
14
+ import { Polling } from '../childs/polling';
15
+ import { Promote } from '../childs/promote';
16
+ import { Restrict } from '../childs/restrict';
17
+ import { Send } from '../childs/send';
18
+ import { Set } from '../childs/set';
19
+ import { Stop } from '../childs/stop';
20
+ import { Unban } from '../childs/unban';
21
+ import { Unpin } from '../childs/unpin';
22
+ import { Upload } from '../childs/upload';
23
+ import { Webhook } from '../childs/webhook';
24
+ import { UpdateType } from '../definitions/enums';
25
+ import { Handler, HandlerOptions, TelegramName } from '../definitions/interfaces';
26
+ import { HandlerMiddleware } from '../definitions/types';
27
+ import { API } from './api';
28
+ import { Builder } from './builder';
29
+ export declare class Telegram {
30
+ /** INTERNAL */
31
+ api: API;
32
+ handlers: Handler[];
33
+ hostname: string;
34
+ id: number;
35
+ name: TelegramName;
36
+ port: number;
37
+ token: string;
38
+ username: string;
39
+ /** BUILDERS */
40
+ builder: Builder;
41
+ /** CHILDS */
42
+ add: Add;
43
+ answer: Answer;
44
+ create: Create;
45
+ delete: Delete;
46
+ download: Download;
47
+ edit: Edit;
48
+ export: Export;
49
+ forward: Forward;
50
+ get: Get;
51
+ ban: Ban;
52
+ leave: Leave;
53
+ pin: Pin;
54
+ polling: Polling;
55
+ promote: Promote;
56
+ restrict: Restrict;
57
+ send: Send;
58
+ set: Set;
59
+ stop: Stop;
60
+ unban: Unban;
61
+ unpin: Unpin;
62
+ upload: Upload;
63
+ webhook: Webhook;
64
+ constructor(token: string, hostname?: string, port?: number);
65
+ on<T extends UpdateType, U extends HandlerOptions>(type: T, middleware: HandlerMiddleware<T>, key?: string, description?: string, options?: U): void;
66
+ handle(update: Update): void;
67
+ handleCallbackQuery(query: CallbackQuery): Handler;
68
+ handleChannelPost(post: Message): Handler;
69
+ handleChatJoinRequest(request: ChatJoinRequest): Handler;
70
+ handleChatMember(member: ChatMemberUpdated): Handler;
71
+ handleChosenInlineResult(result: ChosenInlineResult): Handler;
72
+ handleDocument(document: Message): Handler;
73
+ handleEditedChannelPost(post: Message): Handler;
74
+ handleEditedMessage(message: Message): Handler;
75
+ handleInlineQuery(query: InlineQuery): Handler;
76
+ handleMessage(message: Message): Handler;
77
+ handleMyChatMember(member: ChatMemberUpdated): Handler;
78
+ handlePoll(poll: Poll): Handler;
79
+ handlePollAnswer(answer: PollAnswer): Handler;
80
+ handlePreCheckoutQuery(query: PreCheckoutQuery): Handler;
81
+ handleReplyToMessage(reply: Message): Handler;
82
+ handleShippingQuery(query: ShippingQuery): Handler;
83
+ handleStart(start: Message): Handler;
84
+ private findMatchingHandler;
85
+ get commands(): BotCommand[];
86
+ private get handlerIDs();
87
+ }
@@ -0,0 +1,5 @@
1
+ import { CallbackQueryBody } from '../definitions/interfaces';
2
+ export declare class CallbackQueryUtils {
3
+ static decodeBody<T>(data?: string): CallbackQueryBody<T>;
4
+ static encodeBody<T>(data: T, type: string, chatID?: number): string;
5
+ }
@@ -0,0 +1,8 @@
1
+ /// <reference types="node" />
2
+ import { Context } from 'vm';
3
+ import { UpdateType } from '../definitions/enums';
4
+ export declare class CommandUtils {
5
+ static getByContext<T extends UpdateType>(context: Context[T]): string;
6
+ static get(string?: string): string;
7
+ static omit(string: string): string;
8
+ }
@@ -0,0 +1,13 @@
1
+ import { Chat, User } from '@aracna/telegram-bot-types';
2
+ import { UpdateType } from '../definitions/enums';
3
+ import { Context } from '../definitions/interfaces';
4
+ export declare class ContextUtils {
5
+ static getChatID<T extends UpdateType>(context: Context[T]): number;
6
+ static getChatType<T extends UpdateType>(context: Context[T]): string;
7
+ static getChat<T extends UpdateType>(context: Context[T]): Chat;
8
+ static getUserID<T extends UpdateType>(context: Context[T]): number;
9
+ static getUserFirstName<T extends UpdateType>(context: Context[T]): string;
10
+ static getUserLastName<T extends UpdateType>(context: Context[T]): string;
11
+ static getUserUsername<T extends UpdateType>(context: Context[T]): string;
12
+ static getUser<T extends UpdateType>(context: Context[T]): User;
13
+ }
@@ -0,0 +1,5 @@
1
+ export declare class HTMLUtils {
2
+ static tags: string[];
3
+ static sanitize(text: string): string;
4
+ static progress(value: number, minimum?: number, maximum?: number, size?: number): string;
5
+ }
@@ -0,0 +1,4 @@
1
+ import { InlineKeyboardButton } from '@aracna/telegram-bot-types';
2
+ export declare class InlineKeyboardUtils {
3
+ static getButtonsType(buttons: InlineKeyboardButton[]): string;
4
+ }
@@ -0,0 +1,6 @@
1
+ import { MessageEntity } from '@aracna/telegram-bot-types';
2
+ import { MessageBody } from '../definitions/interfaces';
3
+ export declare class ReplyToMessageUtils {
4
+ static decodeBody<T>(entities: MessageEntity[]): MessageBody<T>;
5
+ static encodeBody<T>(data: T, type: string, chatID?: number): string;
6
+ }
@@ -0,0 +1,7 @@
1
+ import { MessageBody } from '../definitions/interfaces';
2
+ export declare class StartUtils {
3
+ static decodeBody<T>(text?: string): MessageBody<T>;
4
+ static encodeBody<T>(data: T, type: string, chatID?: number): string;
5
+ static encodeBodyToHREF<T>(username: string, data: T, type: string, chatID?: number): string;
6
+ static encodeBodyToAnchorTag<T>(username: string, data: T, type: string, children: string, chatID?: number): string;
7
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.REGEXP_COMMAND_WITH_USERNAME = exports.REGEXP_COMMAND = void 0;
4
+ // export const REGEXP_ARRAY: RegExp = /^\[.+\]$/
5
+ exports.REGEXP_COMMAND = /\/[a-z_]+/m;
6
+ exports.REGEXP_COMMAND_WITH_USERNAME = /\/[a-zA-Z0-9_@]+/;
7
+ // export const REGEXP_ID: RegExp = /^[a-z0-9]{16}$/
8
+ // export const REGEXP_NUMBER: RegExp = /^(\+|-)?[0-9]+(\.[0-9])?[0-9]*$/
9
+ // export const REGEXP_OBJECT: RegExp = /^\{.+\}$/
10
+ // export const REGEXP_REPLY_TO_MESSAGE_CHAT_ID: RegExp = /:\s(\+|-)?[0-9]+/m
11
+ // export const REGEXP_USERNAME: RegExp = /[a-zA-Z_0-9]{5,32}/
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UpdateType = exports.LoggerName = void 0;
4
+ var LoggerName;
5
+ (function (LoggerName) {
6
+ LoggerName["MODULE"] = "TELEGRAM_MODULE";
7
+ })(LoggerName = exports.LoggerName || (exports.LoggerName = {}));
8
+ var UpdateType;
9
+ (function (UpdateType) {
10
+ UpdateType["CALLBACK_QUERY"] = "CALLBACK_QUERY";
11
+ UpdateType["CHANNEL_POST"] = "CHANNEL_POST";
12
+ UpdateType["CHAT_JOIN_REQUEST"] = "CHAT_JOIN_REQUEST";
13
+ UpdateType["CHAT_MEMBER"] = "CHAT_MEMBER";
14
+ UpdateType["CHOSEN_INLINE_RESULT"] = "CHOSEN_INLINE_RESULT";
15
+ UpdateType["DOCUMENT"] = "DOCUMENT";
16
+ UpdateType["EDITED_CHANNEL_POST"] = "EDITED_CHANNEL_POST";
17
+ UpdateType["EDITED_MESSAGE"] = "EDITED_MESSAGE";
18
+ UpdateType["INLINE_QUERY"] = "INLINE_QUERY";
19
+ UpdateType["MESSAGE"] = "MESSAGE";
20
+ UpdateType["MY_CHAT_MEMBER"] = "MY_CHAT_MEMBER";
21
+ UpdateType["POLL"] = "POLL";
22
+ UpdateType["POLL_ANSWER"] = "POLL_ANSWER";
23
+ UpdateType["PRE_CHECKOUT_QUERY"] = "PRE_CHECKOUT_QUERY";
24
+ UpdateType["REPLY_TO_MESSAGE"] = "REPLY_TO_MESSAGE";
25
+ UpdateType["SHIPPING_QUERY"] = "SHIPPING_QUERY";
26
+ UpdateType["START"] = "START";
27
+ })(UpdateType = exports.UpdateType || (exports.UpdateType = {}));
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const enums_1 = require("./enums");
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });