@codebam/cf-workers-telegram-bot 7.27.0 → 8.0.0
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.
- package/dist/api.d.ts +30 -0
- package/dist/api.js +37 -0
- package/dist/ctx.d.ts +19 -0
- package/dist/ctx.js +109 -0
- package/dist/main/src/TelegramBot.1.d.ts +0 -0
- package/dist/main/src/TelegramBot.1.js +1 -0
- package/dist/main/src/TelegramBot.d.ts +0 -0
- package/dist/main/src/TelegramBot.js +1 -0
- package/dist/main/src/api.d.ts +14 -0
- package/dist/main/src/api.js +21 -0
- package/dist/main/src/bot_api.d.ts +10 -0
- package/dist/main/src/bot_api.js +11 -0
- package/dist/main/src/commands/ban.d.ts +5 -0
- package/dist/main/src/commands/ban.js +8 -0
- package/dist/main/src/commands/bored.d.ts +5 -0
- package/dist/main/src/commands/bored.js +7 -0
- package/dist/main/src/commands/clear.d.ts +5 -0
- package/dist/main/src/commands/clear.js +14 -0
- package/dist/main/src/commands/code.d.ts +5 -0
- package/dist/main/src/commands/code.js +4 -0
- package/dist/main/src/commands/commandlist.d.ts +5 -0
- package/dist/main/src/commands/commandlist.js +1 -0
- package/dist/main/src/commands/dog.d.ts +5 -0
- package/dist/main/src/commands/dog.js +7 -0
- package/dist/main/src/commands/duckduckgo.d.ts +5 -0
- package/dist/main/src/commands/duckduckgo.js +42 -0
- package/dist/main/src/commands/epoch.d.ts +5 -0
- package/dist/main/src/commands/epoch.js +4 -0
- package/dist/main/src/commands/getchatinfo.d.ts +5 -0
- package/dist/main/src/commands/getchatinfo.js +1 -0
- package/dist/main/src/commands/image.d.ts +5 -0
- package/dist/main/src/commands/image.js +19 -0
- package/dist/main/src/commands/joke.d.ts +5 -0
- package/dist/main/src/commands/joke.js +7 -0
- package/dist/main/src/commands/kanye.d.ts +5 -0
- package/dist/main/src/commands/kanye.js +8 -0
- package/dist/main/src/commands/mute.d.ts +5 -0
- package/dist/main/src/commands/mute.js +8 -0
- package/dist/main/src/commands/ping.d.ts +5 -0
- package/dist/main/src/commands/ping.js +1 -0
- package/dist/main/src/commands/question.d.ts +5 -0
- package/dist/main/src/commands/question.js +74 -0
- package/dist/main/src/commands/roll.d.ts +5 -0
- package/dist/main/src/commands/roll.js +6 -0
- package/dist/main/src/commands/sean.d.ts +5 -0
- package/dist/main/src/commands/sean.js +76 -0
- package/dist/main/src/commands/start.d.ts +5 -0
- package/dist/main/src/commands/start.js +1 -0
- package/dist/main/src/commands/toss.d.ts +5 -0
- package/dist/main/src/commands/toss.js +1 -0
- package/dist/main/src/commands/translate.d.ts +5 -0
- package/dist/main/src/commands/translate.js +26 -0
- package/dist/main/src/handler.d.ts +12 -0
- package/dist/main/src/handler.js +40 -0
- package/dist/main/src/libs.d.ts +5 -0
- package/dist/main/src/libs.js +7 -0
- package/dist/main/src/main.d.ts +4 -0
- package/dist/main/src/main.js +4 -0
- package/dist/main/src/telegram_api.d.ts +34 -0
- package/dist/main/src/telegram_api.js +192 -0
- package/dist/main/src/telegram_bot.d.ts +20 -0
- package/dist/main/src/telegram_bot.js +116 -0
- package/dist/main/src/telegram_commands.d.ts +22 -0
- package/dist/main/src/telegram_commands.js +21 -0
- package/dist/main/src/telegram_webhook.d.ts +10 -0
- package/dist/main/src/telegram_webhook.js +20 -0
- package/dist/main/src/types/Balance.d.ts +6 -0
- package/dist/main/src/types/Balance.js +1 -0
- package/dist/main/src/types/Bored.d.ts +10 -0
- package/dist/main/src/types/Bored.js +1 -0
- package/dist/main/src/types/ChatPermissions.d.ts +17 -0
- package/dist/main/src/types/ChatPermissions.js +1 -0
- package/dist/main/src/types/Command.d.ts +5 -0
- package/dist/main/src/types/Command.js +1 -0
- package/dist/main/src/types/CommandArgs.d.ts +5 -0
- package/dist/main/src/types/CommandArgs.js +1 -0
- package/dist/main/src/types/Commands.d.ts +3 -0
- package/dist/main/src/types/Commands.js +1 -0
- package/dist/main/src/types/Config.d.ts +20 -0
- package/dist/main/src/types/Config.js +33 -0
- package/dist/main/src/types/DDGQueryResponse.d.ts +12 -0
- package/dist/main/src/types/DDGQueryResponse.js +1 -0
- package/dist/main/src/types/DataTypes.d.ts +2 -0
- package/dist/main/src/types/DataTypes.js +1 -0
- package/dist/main/src/types/Joke.d.ts +20 -0
- package/dist/main/src/types/Joke.js +1 -0
- package/dist/main/src/types/Kanye.d.ts +4 -0
- package/dist/main/src/types/Kanye.js +1 -0
- package/dist/main/src/types/Kv.d.ts +3 -0
- package/dist/main/src/types/Kv.js +1 -0
- package/dist/main/src/types/PartialTelegramUpdate.d.ts +11 -0
- package/dist/main/src/types/PartialTelegramUpdate.js +1 -0
- package/dist/main/src/types/TelegramChat.d.ts +21 -0
- package/dist/main/src/types/TelegramChat.js +1 -0
- package/dist/main/src/types/TelegramCommand.d.ts +5 -0
- package/dist/main/src/types/TelegramCommand.js +1 -0
- package/dist/main/src/types/TelegramFrom.d.ts +8 -0
- package/dist/main/src/types/TelegramFrom.js +1 -0
- package/dist/main/src/types/TelegramInlineQuery.d.ts +9 -0
- package/dist/main/src/types/TelegramInlineQuery.js +1 -0
- package/dist/main/src/types/TelegramInlineQueryResult.d.ts +6 -0
- package/dist/main/src/types/TelegramInlineQueryResult.js +8 -0
- package/dist/main/src/types/TelegramInlineQueryResultArticle.d.ts +8 -0
- package/dist/main/src/types/TelegramInlineQueryResultArticle.js +15 -0
- package/dist/main/src/types/TelegramInlineQueryResultPhoto.d.ts +13 -0
- package/dist/main/src/types/TelegramInlineQueryResultPhoto.js +19 -0
- package/dist/main/src/types/TelegramInlineQueryType.d.ts +2 -0
- package/dist/main/src/types/TelegramInlineQueryType.js +1 -0
- package/dist/main/src/types/TelegramInputMessageContent.d.ts +5 -0
- package/dist/main/src/types/TelegramInputMessageContent.js +1 -0
- package/dist/main/src/types/TelegramMessage.d.ts +43 -0
- package/dist/main/src/types/TelegramMessage.js +1 -0
- package/dist/main/src/types/TelegramMessageEntity.d.ts +10 -0
- package/dist/main/src/types/TelegramMessageEntity.js +1 -0
- package/dist/main/src/types/TelegramPhotoSize.d.ts +8 -0
- package/dist/main/src/types/TelegramPhotoSize.js +1 -0
- package/dist/main/src/types/TelegramUpdate.d.ts +13 -0
- package/dist/main/src/types/TelegramUpdate.js +36 -0
- package/dist/main/src/types/TelegramUser.d.ts +12 -0
- package/dist/main/src/types/TelegramUser.js +1 -0
- package/dist/main/src/types/Update.d.ts +3 -0
- package/dist/main/src/types/Update.js +2 -0
- package/dist/main/src/types/WebhookCommands.d.ts +4 -0
- package/dist/main/src/types/WebhookCommands.js +2 -0
- package/dist/main/src/types/localhost.d.ts +3 -0
- package/dist/main/src/types/localhost.js +1 -0
- package/dist/main/src/types/types.d.ts +1 -0
- package/dist/main/src/types/types.js +1 -0
- package/dist/main/src/types.d.ts +26 -0
- package/dist/main/src/types.js +8 -0
- package/dist/main/src/webhook.d.ts +10 -0
- package/dist/main/src/webhook.js +15 -0
- package/dist/telegram_api.d.ts +2 -1
- package/dist/telegram_api.js +1 -0
- package/dist/telegram_bot.js +4 -0
- package/dist/telegram_execution_context.js +10 -0
- package/dist/types/Balance.d.ts +6 -0
- package/dist/types/Balance.js +1 -0
- package/dist/types/Bored.d.ts +10 -0
- package/dist/types/Bored.js +1 -0
- package/dist/types/DDGQueryResponse.d.ts +12 -0
- package/dist/types/DDGQueryResponse.js +1 -0
- package/dist/types/Joke.d.ts +20 -0
- package/dist/types/Joke.js +1 -0
- package/dist/types/Kanye.d.ts +4 -0
- package/dist/types/Kanye.js +1 -0
- package/dist/types/Kv.d.ts +3 -0
- package/dist/types/Kv.js +1 -0
- package/dist/types/PartialTelegramUpdate.d.ts +2 -0
- package/dist/types/SerializableData.d.ts +2 -0
- package/dist/types/SerializableData.js +1 -0
- package/dist/types/TelegramBusinessMessage.d.ts +47 -0
- package/dist/types/TelegramBusinessMessage.js +1 -0
- package/dist/types/TelegramUpdate.d.ts +2 -0
- package/dist/types/TelegramUpdate.js +2 -0
- package/dist/types/Update.d.ts +3 -0
- package/dist/types/Update.js +2 -0
- package/dist/types/WebhookCommands.d.ts +4 -0
- package/dist/types/WebhookCommands.js +2 -0
- package/dist/types/localhost.d.ts +3 -0
- package/dist/types/localhost.js +1 -0
- package/dist/webhook.js +1 -1
- package/dist/worker/src/worker.d.ts +18 -0
- package/dist/worker/src/worker.js +81 -0
- package/package.json +7 -7
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import Webhook from './webhook';
|
|
2
|
+
import { sha256, addSearchParams } from './libs';
|
|
3
|
+
export default class TelegramWebhook extends Webhook {
|
|
4
|
+
constructor(api, token, url) {
|
|
5
|
+
super(api, token, url);
|
|
6
|
+
}
|
|
7
|
+
set = async (drop_pending_updates = true) => sha256(this.token).then((access_key) => fetch(addSearchParams(new URL(`${this.api.origin}${this.api.pathname}/setWebhook`), {
|
|
8
|
+
url: new URL(`${this.url.origin}${this.url.pathname}${access_key}`).href,
|
|
9
|
+
max_connections: '100',
|
|
10
|
+
allowed_updates: JSON.stringify(['message', 'inline_query']),
|
|
11
|
+
drop_pending_updates: drop_pending_updates.toString(),
|
|
12
|
+
})));
|
|
13
|
+
get = async () => fetch(new URL(`${this.api.origin}${this.api.pathname}/getWebhookInfo`));
|
|
14
|
+
delete = async () => fetch(new URL(`${this.api.origin}${this.api.pathname}/deleteWebhook`));
|
|
15
|
+
commands = {
|
|
16
|
+
set: this.set,
|
|
17
|
+
get: this.get,
|
|
18
|
+
delete: this.delete,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
type ChatPermissions = {
|
|
2
|
+
can_send_messages?: boolean;
|
|
3
|
+
can_send_audios?: boolean;
|
|
4
|
+
can_send_documents?: boolean;
|
|
5
|
+
can_send_photos?: boolean;
|
|
6
|
+
can_send_videos?: boolean;
|
|
7
|
+
can_send_video_notes?: boolean;
|
|
8
|
+
can_send_voice_notes?: boolean;
|
|
9
|
+
can_send_polls?: boolean;
|
|
10
|
+
can_send_other_messages?: boolean;
|
|
11
|
+
can_add_web_page_previews?: boolean;
|
|
12
|
+
can_change_info?: boolean;
|
|
13
|
+
can_invite_users?: boolean;
|
|
14
|
+
can_pin_messages?: boolean;
|
|
15
|
+
can_manage_topics?: boolean;
|
|
16
|
+
};
|
|
17
|
+
export default ChatPermissions;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/// <reference types="@cloudflare/workers-types" />
|
|
2
|
+
import Command from './Command';
|
|
3
|
+
import Kv from './Kv';
|
|
4
|
+
import BotApi from '../bot_api';
|
|
5
|
+
import Handler from '../handler';
|
|
6
|
+
import Webhook from '../webhook';
|
|
7
|
+
export default class Config {
|
|
8
|
+
bot_name: string;
|
|
9
|
+
api: typeof BotApi;
|
|
10
|
+
webhook: Webhook;
|
|
11
|
+
commands: Record<string, Command>;
|
|
12
|
+
kv: Kv;
|
|
13
|
+
url: URL;
|
|
14
|
+
handler: Handler;
|
|
15
|
+
ai: any;
|
|
16
|
+
db: any;
|
|
17
|
+
r2: any;
|
|
18
|
+
chat_model: string;
|
|
19
|
+
constructor(config?: Partial<Config>);
|
|
20
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import BotApi from '../bot_api';
|
|
2
|
+
import Handler from '../handler';
|
|
3
|
+
import Webhook from '../webhook';
|
|
4
|
+
import localhost from './localhost';
|
|
5
|
+
export default class Config {
|
|
6
|
+
bot_name;
|
|
7
|
+
api;
|
|
8
|
+
webhook;
|
|
9
|
+
commands;
|
|
10
|
+
kv;
|
|
11
|
+
url;
|
|
12
|
+
handler;
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
14
|
+
ai;
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
16
|
+
db;
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
|
+
r2;
|
|
19
|
+
chat_model;
|
|
20
|
+
constructor(config = {}) {
|
|
21
|
+
this.bot_name = config.bot_name || '';
|
|
22
|
+
this.api = config.api || BotApi;
|
|
23
|
+
this.webhook = config.webhook || new Webhook(localhost, '', localhost);
|
|
24
|
+
this.commands = config.commands || {};
|
|
25
|
+
this.kv = config.kv;
|
|
26
|
+
this.url = config.url || new URL(localhost);
|
|
27
|
+
this.handler = config.handler || new Handler([]);
|
|
28
|
+
this.ai = config.ai;
|
|
29
|
+
this.db = config.db;
|
|
30
|
+
this.r2 = config.r2;
|
|
31
|
+
this.chat_model = config.chat_model;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
type Joke = {
|
|
2
|
+
error: boolean;
|
|
3
|
+
category: string;
|
|
4
|
+
type: string;
|
|
5
|
+
setup?: string;
|
|
6
|
+
delivery?: string;
|
|
7
|
+
joke?: string;
|
|
8
|
+
flags: {
|
|
9
|
+
nsfw: boolean;
|
|
10
|
+
religious: boolean;
|
|
11
|
+
political: boolean;
|
|
12
|
+
racist: boolean;
|
|
13
|
+
sexist: boolean;
|
|
14
|
+
explicit: boolean;
|
|
15
|
+
};
|
|
16
|
+
id: number;
|
|
17
|
+
safe: boolean;
|
|
18
|
+
lang: string;
|
|
19
|
+
};
|
|
20
|
+
export default Joke;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import TelegramInlineQuery from './TelegramInlineQuery';
|
|
2
|
+
import TelegramMessage from './TelegramMessage';
|
|
3
|
+
type PartialTelegramUpdate = {
|
|
4
|
+
update_id?: number;
|
|
5
|
+
message?: TelegramMessage;
|
|
6
|
+
edited_message?: TelegramMessage;
|
|
7
|
+
channel_post?: TelegramMessage;
|
|
8
|
+
edited_channel_post?: TelegramMessage;
|
|
9
|
+
inline_query?: TelegramInlineQuery;
|
|
10
|
+
};
|
|
11
|
+
export default PartialTelegramUpdate;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import TelegramMessage from './TelegramMessage';
|
|
2
|
+
type TelegramChat = {
|
|
3
|
+
id: number;
|
|
4
|
+
type: string;
|
|
5
|
+
title?: string;
|
|
6
|
+
username?: string;
|
|
7
|
+
first_name?: string;
|
|
8
|
+
last_name?: string;
|
|
9
|
+
bio?: string;
|
|
10
|
+
has_private_forwards: boolean;
|
|
11
|
+
description?: string;
|
|
12
|
+
invite_link?: string;
|
|
13
|
+
pinned_message?: TelegramMessage;
|
|
14
|
+
slow_mode_delay?: number;
|
|
15
|
+
message_auto_delete_time?: number;
|
|
16
|
+
has_protected_content?: boolean;
|
|
17
|
+
sticker_set_name?: string;
|
|
18
|
+
can_set_sticker_set?: boolean;
|
|
19
|
+
linked_chat_id?: number;
|
|
20
|
+
};
|
|
21
|
+
export default TelegramChat;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/// <reference types="@cloudflare/workers-types" />
|
|
2
|
+
import TelegramBot from '../telegram_bot';
|
|
3
|
+
import TelegramUpdate from './TelegramUpdate';
|
|
4
|
+
type TelegramCommand = (bot: TelegramBot, update: TelegramUpdate, args: string[]) => Promise<Response>;
|
|
5
|
+
export default TelegramCommand;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import TelegramInlineQueryResult from './TelegramInlineQueryResult';
|
|
2
|
+
import TelegramInputMessageContent from './TelegramInputMessageContent';
|
|
3
|
+
export default class TelegramInlineQueryResultArticle extends TelegramInlineQueryResult {
|
|
4
|
+
title: string;
|
|
5
|
+
input_message_content: TelegramInputMessageContent;
|
|
6
|
+
thumb_url: string;
|
|
7
|
+
constructor(content: string, title?: string, parse_mode?: string, thumb_url?: string);
|
|
8
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import TelegramInlineQueryResult from './TelegramInlineQueryResult';
|
|
2
|
+
export default class TelegramInlineQueryResultArticle extends TelegramInlineQueryResult {
|
|
3
|
+
title;
|
|
4
|
+
input_message_content;
|
|
5
|
+
thumb_url;
|
|
6
|
+
constructor(content, title = content, parse_mode = '', thumb_url = '') {
|
|
7
|
+
super('article');
|
|
8
|
+
this.title = title;
|
|
9
|
+
this.input_message_content = {
|
|
10
|
+
message_text: content.toString(),
|
|
11
|
+
parse_mode,
|
|
12
|
+
};
|
|
13
|
+
this.thumb_url = thumb_url;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import TelegramInlineQueryResult from './TelegramInlineQueryResult';
|
|
2
|
+
export default class TelegramInlineQueryResultPhoto extends TelegramInlineQueryResult {
|
|
3
|
+
photo_url: string;
|
|
4
|
+
thumb_url: string;
|
|
5
|
+
photo_width?: number;
|
|
6
|
+
photo_height?: number;
|
|
7
|
+
title?: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
caption?: string;
|
|
10
|
+
parse_mode?: string;
|
|
11
|
+
caption_entities?: string;
|
|
12
|
+
constructor(photo: string);
|
|
13
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import TelegramInlineQueryResult from './TelegramInlineQueryResult';
|
|
2
|
+
export default class TelegramInlineQueryResultPhoto extends TelegramInlineQueryResult {
|
|
3
|
+
photo_url; // must be a jpg
|
|
4
|
+
thumb_url;
|
|
5
|
+
photo_width;
|
|
6
|
+
photo_height;
|
|
7
|
+
title;
|
|
8
|
+
description;
|
|
9
|
+
caption;
|
|
10
|
+
parse_mode;
|
|
11
|
+
caption_entities;
|
|
12
|
+
// reply_markup?: TelegramInlineKeyboardMarkup;
|
|
13
|
+
// input_message_content?: TelegramInputMessageContent;
|
|
14
|
+
constructor(photo) {
|
|
15
|
+
super('photo');
|
|
16
|
+
this.photo_url = photo;
|
|
17
|
+
this.thumb_url = photo;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import TelegramChat from './TelegramChat';
|
|
2
|
+
import TelegramFrom from './TelegramFrom';
|
|
3
|
+
import TelegramMessageEntity from './TelegramMessageEntity';
|
|
4
|
+
import TelegramPhotoSize from './TelegramPhotoSize';
|
|
5
|
+
import TelegramUser from './TelegramUser';
|
|
6
|
+
type TelegramMessage = {
|
|
7
|
+
message_id: number;
|
|
8
|
+
from: TelegramFrom;
|
|
9
|
+
sender_chat?: TelegramChat;
|
|
10
|
+
date: number;
|
|
11
|
+
chat: TelegramChat;
|
|
12
|
+
forward_from?: TelegramUser;
|
|
13
|
+
forward_from_chat?: TelegramChat;
|
|
14
|
+
forward_from_message_id?: number;
|
|
15
|
+
forward_signature?: string;
|
|
16
|
+
forward_sender_name?: string;
|
|
17
|
+
forward_date?: number;
|
|
18
|
+
is_automatic_forward?: boolean;
|
|
19
|
+
reply_to_message?: TelegramMessage;
|
|
20
|
+
via_bot?: TelegramUser;
|
|
21
|
+
edit_date?: number;
|
|
22
|
+
has_protected_content?: boolean;
|
|
23
|
+
media_group_id?: string;
|
|
24
|
+
author_signature?: string;
|
|
25
|
+
text?: string;
|
|
26
|
+
entities?: TelegramMessageEntity[];
|
|
27
|
+
photo?: TelegramPhotoSize[];
|
|
28
|
+
caption?: string;
|
|
29
|
+
caption_entities?: TelegramMessageEntity[];
|
|
30
|
+
new_chat_members?: TelegramUser[];
|
|
31
|
+
new_chat_member?: TelegramUser;
|
|
32
|
+
left_chat_member?: TelegramUser;
|
|
33
|
+
new_chat_title?: string;
|
|
34
|
+
delete_chat_photo?: boolean;
|
|
35
|
+
group_chat_created?: boolean;
|
|
36
|
+
supergroup_chat_created?: boolean;
|
|
37
|
+
channel_chat_created?: boolean;
|
|
38
|
+
migrate_to_chat_id?: number;
|
|
39
|
+
migrate_from_chat_id?: number;
|
|
40
|
+
pinned_message?: TelegramMessage;
|
|
41
|
+
connected_website?: string;
|
|
42
|
+
};
|
|
43
|
+
export default TelegramMessage;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import TelegramInlineQuery from './TelegramInlineQuery';
|
|
2
|
+
import TelegramMessage from './TelegramMessage';
|
|
3
|
+
import Update from './Update';
|
|
4
|
+
import PartialTelegramUpdate from './PartialTelegramUpdate';
|
|
5
|
+
export default class TelegramUpdate extends Update {
|
|
6
|
+
update_id: number;
|
|
7
|
+
message?: TelegramMessage;
|
|
8
|
+
edited_message?: TelegramMessage;
|
|
9
|
+
channel_post?: TelegramMessage;
|
|
10
|
+
edited_channel_post?: TelegramMessage;
|
|
11
|
+
inline_query?: TelegramInlineQuery;
|
|
12
|
+
constructor(update: PartialTelegramUpdate);
|
|
13
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import Update from './Update';
|
|
2
|
+
export default class TelegramUpdate extends Update {
|
|
3
|
+
update_id;
|
|
4
|
+
message;
|
|
5
|
+
edited_message;
|
|
6
|
+
channel_post;
|
|
7
|
+
edited_channel_post;
|
|
8
|
+
inline_query;
|
|
9
|
+
// chosen_inline_result?: TelegramChosenInlineResult;
|
|
10
|
+
// callback_query?: TelegramCallbackQuery;
|
|
11
|
+
// shipping_query?: TelegramShippingQuery;
|
|
12
|
+
// pre_checkout_query?: TelegramPreCheckoutQuery;
|
|
13
|
+
// poll?: TelegramPoll;
|
|
14
|
+
// poll_answer?: TelegramPollAnswer;
|
|
15
|
+
// my_chat_member?: TelegramChatMemberUpdated;
|
|
16
|
+
// chat_member?: TelegramChatMemberUpdated;
|
|
17
|
+
// chat_join_request: TelegramChatJoinRequest;
|
|
18
|
+
constructor(update) {
|
|
19
|
+
super();
|
|
20
|
+
this.update_id = update.update_id || 0;
|
|
21
|
+
this.message = update.message;
|
|
22
|
+
this.edited_message = update.edited_message;
|
|
23
|
+
this.channel_post = update.channel_post;
|
|
24
|
+
this.edited_channel_post = update.edited_channel_post;
|
|
25
|
+
this.inline_query = update.inline_query;
|
|
26
|
+
// chosen_inline_result = update.chosen_inline_result;
|
|
27
|
+
// callback_query = update.callback_query;
|
|
28
|
+
// shipping_query = update.shipping_query;
|
|
29
|
+
// pre_checkout_query = update.pre_checkout_query;
|
|
30
|
+
// poll = update.poll;
|
|
31
|
+
// poll_answer = update.poll_answer;
|
|
32
|
+
// my_chat_member = update.my_chat_member;
|
|
33
|
+
// chat_member = update.chat_member;
|
|
34
|
+
// chat_join_request = update.chat_join_request;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
type TelegramUser = {
|
|
2
|
+
id: number;
|
|
3
|
+
is_bot: boolean;
|
|
4
|
+
first_name: string;
|
|
5
|
+
last_name?: string;
|
|
6
|
+
username?: string;
|
|
7
|
+
language_code?: string;
|
|
8
|
+
can_join_groups?: boolean;
|
|
9
|
+
can_read_all_group_messages?: boolean;
|
|
10
|
+
supports_inline_queries: boolean;
|
|
11
|
+
};
|
|
12
|
+
export default TelegramUser;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default new URL('http://localhost');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Webhook };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Webhook };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import TelegramCommand from './types/TelegramCommand';
|
|
2
|
+
import Kv from './types/Kv';
|
|
3
|
+
import localhost from './types/localhost';
|
|
4
|
+
import WebhookCommands from './types/WebhookCommands';
|
|
5
|
+
import Joke from './types/Joke';
|
|
6
|
+
import Bored from './types/Bored';
|
|
7
|
+
import Balance from './types/Balance';
|
|
8
|
+
import TelegramFrom from './types/TelegramFrom';
|
|
9
|
+
import TelegramChat from './types/TelegramChat';
|
|
10
|
+
import TelegramUser from './types/TelegramUser';
|
|
11
|
+
import TelegramMessageEntity from './types/TelegramMessageEntity';
|
|
12
|
+
import TelegramPhotoSize from './types/TelegramPhotoSize';
|
|
13
|
+
import TelegramMessage from './types/TelegramMessage';
|
|
14
|
+
import TelegramInputMessageContent from './types/TelegramInputMessageContent';
|
|
15
|
+
import TelegramInlineQuery from './types/TelegramInlineQuery';
|
|
16
|
+
import Update from './types/Update';
|
|
17
|
+
import TelegramUpdate from './types/TelegramUpdate';
|
|
18
|
+
import PartialTelegramUpdate from './types/PartialTelegramUpdate';
|
|
19
|
+
import TelegramInlineQueryType from './types/TelegramInlineQueryType';
|
|
20
|
+
import TelegramInlineQueryResult from './types/TelegramInlineQueryResult';
|
|
21
|
+
import TelegramInlineQueryResultPhoto from './types/TelegramInlineQueryResultPhoto';
|
|
22
|
+
import TelegramInlineQueryResultArticle from './types/TelegramInlineQueryResultArticle';
|
|
23
|
+
import DDGQueryResponse from './types/DDGQueryResponse';
|
|
24
|
+
import ChatPermissions from './types/ChatPermissions';
|
|
25
|
+
import Kanye from './types/Kanye';
|
|
26
|
+
export { TelegramCommand, Kv, localhost, WebhookCommands, Joke, Bored, Balance, TelegramFrom, TelegramChat, TelegramUser, TelegramMessageEntity, TelegramPhotoSize, TelegramMessage, TelegramInputMessageContent, TelegramInlineQuery, Update, TelegramUpdate, PartialTelegramUpdate, TelegramInlineQueryType, TelegramInlineQueryResult, TelegramInlineQueryResultPhoto, TelegramInlineQueryResultArticle, DDGQueryResponse, ChatPermissions, Kanye, };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import localhost from './types/localhost';
|
|
2
|
+
import WebhookCommands from './types/WebhookCommands';
|
|
3
|
+
import Update from './types/Update';
|
|
4
|
+
import TelegramUpdate from './types/TelegramUpdate';
|
|
5
|
+
import TelegramInlineQueryResult from './types/TelegramInlineQueryResult';
|
|
6
|
+
import TelegramInlineQueryResultPhoto from './types/TelegramInlineQueryResultPhoto';
|
|
7
|
+
import TelegramInlineQueryResultArticle from './types/TelegramInlineQueryResultArticle';
|
|
8
|
+
export { localhost, WebhookCommands, Update, TelegramUpdate, TelegramInlineQueryResult, TelegramInlineQueryResultPhoto, TelegramInlineQueryResultArticle, };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="@cloudflare/workers-types" />
|
|
2
|
+
import { WebhookCommands } from './types';
|
|
3
|
+
export default class Webhook {
|
|
4
|
+
api: URL;
|
|
5
|
+
token: string;
|
|
6
|
+
url: URL;
|
|
7
|
+
commands: WebhookCommands;
|
|
8
|
+
constructor(api: URL, token: string, url: URL);
|
|
9
|
+
process: (url: URL) => Promise<Response>;
|
|
10
|
+
}
|