@codebam/cf-workers-telegram-bot 8.0.0 → 8.1.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/telegram_api.d.ts +5 -0
- package/dist/telegram_api.js +5 -0
- package/dist/telegram_execution_context.d.ts +1 -0
- package/dist/telegram_execution_context.js +17 -0
- package/package.json +7 -7
- package/dist/api.d.ts +0 -30
- package/dist/api.js +0 -37
- package/dist/ctx.d.ts +0 -19
- package/dist/ctx.js +0 -109
- package/dist/main/src/TelegramBot.1.d.ts +0 -0
- package/dist/main/src/TelegramBot.1.js +0 -1
- package/dist/main/src/TelegramBot.d.ts +0 -0
- package/dist/main/src/TelegramBot.js +0 -1
- package/dist/main/src/api.d.ts +0 -14
- package/dist/main/src/api.js +0 -21
- package/dist/main/src/bot_api.d.ts +0 -10
- package/dist/main/src/bot_api.js +0 -11
- package/dist/main/src/commands/ban.d.ts +0 -5
- package/dist/main/src/commands/ban.js +0 -8
- package/dist/main/src/commands/bored.d.ts +0 -5
- package/dist/main/src/commands/bored.js +0 -7
- package/dist/main/src/commands/clear.d.ts +0 -5
- package/dist/main/src/commands/clear.js +0 -14
- package/dist/main/src/commands/code.d.ts +0 -5
- package/dist/main/src/commands/code.js +0 -4
- package/dist/main/src/commands/commandlist.d.ts +0 -5
- package/dist/main/src/commands/commandlist.js +0 -1
- package/dist/main/src/commands/dog.d.ts +0 -5
- package/dist/main/src/commands/dog.js +0 -7
- package/dist/main/src/commands/duckduckgo.d.ts +0 -5
- package/dist/main/src/commands/duckduckgo.js +0 -42
- package/dist/main/src/commands/epoch.d.ts +0 -5
- package/dist/main/src/commands/epoch.js +0 -4
- package/dist/main/src/commands/getchatinfo.d.ts +0 -5
- package/dist/main/src/commands/getchatinfo.js +0 -1
- package/dist/main/src/commands/image.d.ts +0 -5
- package/dist/main/src/commands/image.js +0 -19
- package/dist/main/src/commands/joke.d.ts +0 -5
- package/dist/main/src/commands/joke.js +0 -7
- package/dist/main/src/commands/kanye.d.ts +0 -5
- package/dist/main/src/commands/kanye.js +0 -8
- package/dist/main/src/commands/mute.d.ts +0 -5
- package/dist/main/src/commands/mute.js +0 -8
- package/dist/main/src/commands/ping.d.ts +0 -5
- package/dist/main/src/commands/ping.js +0 -1
- package/dist/main/src/commands/question.d.ts +0 -5
- package/dist/main/src/commands/question.js +0 -74
- package/dist/main/src/commands/roll.d.ts +0 -5
- package/dist/main/src/commands/roll.js +0 -6
- package/dist/main/src/commands/sean.d.ts +0 -5
- package/dist/main/src/commands/sean.js +0 -76
- package/dist/main/src/commands/start.d.ts +0 -5
- package/dist/main/src/commands/start.js +0 -1
- package/dist/main/src/commands/toss.d.ts +0 -5
- package/dist/main/src/commands/toss.js +0 -1
- package/dist/main/src/commands/translate.d.ts +0 -5
- package/dist/main/src/commands/translate.js +0 -26
- package/dist/main/src/handler.d.ts +0 -12
- package/dist/main/src/handler.js +0 -40
- package/dist/main/src/libs.d.ts +0 -5
- package/dist/main/src/libs.js +0 -7
- package/dist/main/src/main.d.ts +0 -4
- package/dist/main/src/main.js +0 -4
- package/dist/main/src/telegram_api.d.ts +0 -34
- package/dist/main/src/telegram_api.js +0 -192
- package/dist/main/src/telegram_bot.d.ts +0 -20
- package/dist/main/src/telegram_bot.js +0 -116
- package/dist/main/src/telegram_commands.d.ts +0 -22
- package/dist/main/src/telegram_commands.js +0 -21
- package/dist/main/src/telegram_webhook.d.ts +0 -10
- package/dist/main/src/telegram_webhook.js +0 -20
- package/dist/main/src/types/Balance.d.ts +0 -6
- package/dist/main/src/types/Balance.js +0 -1
- package/dist/main/src/types/Bored.d.ts +0 -10
- package/dist/main/src/types/Bored.js +0 -1
- package/dist/main/src/types/ChatPermissions.d.ts +0 -17
- package/dist/main/src/types/ChatPermissions.js +0 -1
- package/dist/main/src/types/Command.d.ts +0 -5
- package/dist/main/src/types/Command.js +0 -1
- package/dist/main/src/types/CommandArgs.d.ts +0 -5
- package/dist/main/src/types/CommandArgs.js +0 -1
- package/dist/main/src/types/Commands.d.ts +0 -3
- package/dist/main/src/types/Commands.js +0 -1
- package/dist/main/src/types/Config.d.ts +0 -20
- package/dist/main/src/types/Config.js +0 -33
- package/dist/main/src/types/DDGQueryResponse.d.ts +0 -12
- package/dist/main/src/types/DDGQueryResponse.js +0 -1
- package/dist/main/src/types/DataTypes.d.ts +0 -2
- package/dist/main/src/types/DataTypes.js +0 -1
- package/dist/main/src/types/Joke.d.ts +0 -20
- package/dist/main/src/types/Joke.js +0 -1
- package/dist/main/src/types/Kanye.d.ts +0 -4
- package/dist/main/src/types/Kanye.js +0 -1
- package/dist/main/src/types/Kv.d.ts +0 -3
- package/dist/main/src/types/Kv.js +0 -1
- package/dist/main/src/types/PartialTelegramUpdate.d.ts +0 -11
- package/dist/main/src/types/PartialTelegramUpdate.js +0 -1
- package/dist/main/src/types/TelegramChat.d.ts +0 -21
- package/dist/main/src/types/TelegramChat.js +0 -1
- package/dist/main/src/types/TelegramCommand.d.ts +0 -5
- package/dist/main/src/types/TelegramCommand.js +0 -1
- package/dist/main/src/types/TelegramFrom.d.ts +0 -8
- package/dist/main/src/types/TelegramFrom.js +0 -1
- package/dist/main/src/types/TelegramInlineQuery.d.ts +0 -9
- package/dist/main/src/types/TelegramInlineQuery.js +0 -1
- package/dist/main/src/types/TelegramInlineQueryResult.d.ts +0 -6
- package/dist/main/src/types/TelegramInlineQueryResult.js +0 -8
- package/dist/main/src/types/TelegramInlineQueryResultArticle.d.ts +0 -8
- package/dist/main/src/types/TelegramInlineQueryResultArticle.js +0 -15
- package/dist/main/src/types/TelegramInlineQueryResultPhoto.d.ts +0 -13
- package/dist/main/src/types/TelegramInlineQueryResultPhoto.js +0 -19
- package/dist/main/src/types/TelegramInlineQueryType.d.ts +0 -2
- package/dist/main/src/types/TelegramInlineQueryType.js +0 -1
- package/dist/main/src/types/TelegramInputMessageContent.d.ts +0 -5
- package/dist/main/src/types/TelegramInputMessageContent.js +0 -1
- package/dist/main/src/types/TelegramMessage.d.ts +0 -43
- package/dist/main/src/types/TelegramMessage.js +0 -1
- package/dist/main/src/types/TelegramMessageEntity.d.ts +0 -10
- package/dist/main/src/types/TelegramMessageEntity.js +0 -1
- package/dist/main/src/types/TelegramPhotoSize.d.ts +0 -8
- package/dist/main/src/types/TelegramPhotoSize.js +0 -1
- package/dist/main/src/types/TelegramUpdate.d.ts +0 -13
- package/dist/main/src/types/TelegramUpdate.js +0 -36
- package/dist/main/src/types/TelegramUser.d.ts +0 -12
- package/dist/main/src/types/TelegramUser.js +0 -1
- package/dist/main/src/types/Update.d.ts +0 -3
- package/dist/main/src/types/Update.js +0 -2
- package/dist/main/src/types/WebhookCommands.d.ts +0 -4
- package/dist/main/src/types/WebhookCommands.js +0 -2
- package/dist/main/src/types/localhost.d.ts +0 -3
- package/dist/main/src/types/localhost.js +0 -1
- package/dist/main/src/types/types.d.ts +0 -1
- package/dist/main/src/types/types.js +0 -1
- package/dist/main/src/types.d.ts +0 -26
- package/dist/main/src/types.js +0 -8
- package/dist/main/src/webhook.d.ts +0 -10
- package/dist/main/src/webhook.js +0 -15
- package/dist/types/Balance.d.ts +0 -6
- package/dist/types/Balance.js +0 -1
- package/dist/types/Bored.d.ts +0 -10
- package/dist/types/Bored.js +0 -1
- package/dist/types/DDGQueryResponse.d.ts +0 -12
- package/dist/types/DDGQueryResponse.js +0 -1
- package/dist/types/Joke.d.ts +0 -20
- package/dist/types/Joke.js +0 -1
- package/dist/types/Kanye.d.ts +0 -4
- package/dist/types/Kanye.js +0 -1
- package/dist/types/Kv.d.ts +0 -3
- package/dist/types/Kv.js +0 -1
- package/dist/types/SerializableData.d.ts +0 -2
- package/dist/types/SerializableData.js +0 -1
- package/dist/types/Update.d.ts +0 -3
- package/dist/types/Update.js +0 -2
- package/dist/types/WebhookCommands.d.ts +0 -4
- package/dist/types/WebhookCommands.js +0 -2
- package/dist/types/localhost.d.ts +0 -3
- package/dist/types/localhost.js +0 -1
- package/dist/worker/src/worker.d.ts +0 -18
- package/dist/worker/src/worker.js +0 -81
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import { TelegramInlineQueryResultArticle, TelegramUpdate } from './types';
|
|
2
|
-
export default class TelegramBot {
|
|
3
|
-
token;
|
|
4
|
-
webhook;
|
|
5
|
-
update;
|
|
6
|
-
api;
|
|
7
|
-
update_type;
|
|
8
|
-
constructor(token) {
|
|
9
|
-
this.token = token;
|
|
10
|
-
this.webhook = new Webhook('', new Request('http://127.0.0.1'));
|
|
11
|
-
this.update = new TelegramUpdate({});
|
|
12
|
-
this.api = new URL('https://api.telegram.org/bot' + token);
|
|
13
|
-
this.update_type = '';
|
|
14
|
-
}
|
|
15
|
-
on(event, callback) {
|
|
16
|
-
if (event !== 'on') {
|
|
17
|
-
// eslint-disable-next-line
|
|
18
|
-
// @ts-ignore TS7053
|
|
19
|
-
this[event] = callback;
|
|
20
|
-
}
|
|
21
|
-
return this;
|
|
22
|
-
}
|
|
23
|
-
async handle(request) {
|
|
24
|
-
this.webhook = new Webhook(this.token, request);
|
|
25
|
-
if (request.method === 'POST') {
|
|
26
|
-
this.update = await request.json();
|
|
27
|
-
}
|
|
28
|
-
const url = new URL(request.url);
|
|
29
|
-
if (`/${this.token}` === url.pathname) {
|
|
30
|
-
switch (url.searchParams.get('command')) {
|
|
31
|
-
case 'set':
|
|
32
|
-
return this.webhook.set();
|
|
33
|
-
default:
|
|
34
|
-
break;
|
|
35
|
-
}
|
|
36
|
-
console.log(this.update);
|
|
37
|
-
if (this.update.message?.text) {
|
|
38
|
-
this.update_type = 'message';
|
|
39
|
-
}
|
|
40
|
-
else if (this.update.inline_query?.query) {
|
|
41
|
-
this.update_type = 'inline';
|
|
42
|
-
}
|
|
43
|
-
let command = 'default';
|
|
44
|
-
let args = [];
|
|
45
|
-
switch (this.update_type) {
|
|
46
|
-
case 'message': {
|
|
47
|
-
// @ts-expect-error already checked above
|
|
48
|
-
args = this.update.message.text.split(' ');
|
|
49
|
-
break;
|
|
50
|
-
}
|
|
51
|
-
case 'inline': {
|
|
52
|
-
// @ts-expect-error already checked above
|
|
53
|
-
args = this.update.inline_query.query.split(' ');
|
|
54
|
-
break;
|
|
55
|
-
}
|
|
56
|
-
default:
|
|
57
|
-
break;
|
|
58
|
-
}
|
|
59
|
-
if (args.at(0)?.startsWith('/')) {
|
|
60
|
-
// @ts-expect-error already checked above
|
|
61
|
-
command = args.at(0).slice(1);
|
|
62
|
-
}
|
|
63
|
-
// eslint-disable-next-line
|
|
64
|
-
// @ts-ignore
|
|
65
|
-
if (!this[command] || command === 'on') {
|
|
66
|
-
command = 'default';
|
|
67
|
-
}
|
|
68
|
-
// eslint-disable-next-line
|
|
69
|
-
// @ts-ignore
|
|
70
|
-
return this[command]?.();
|
|
71
|
-
}
|
|
72
|
-
return new Response('ok');
|
|
73
|
-
}
|
|
74
|
-
async reply(message) {
|
|
75
|
-
switch (this.update_type) {
|
|
76
|
-
case 'message': {
|
|
77
|
-
const request = new URL(this.api + '/sendMessage');
|
|
78
|
-
const params = new URLSearchParams();
|
|
79
|
-
params.append('chat_id', this.update.message?.chat.id.toString() ?? '');
|
|
80
|
-
params.append('reply_to_message_id', this.update.message?.message_id.toString() ?? '');
|
|
81
|
-
params.append('text', message);
|
|
82
|
-
console.log(`${request}?${params}`);
|
|
83
|
-
await fetch(`${request}?${params}`);
|
|
84
|
-
break;
|
|
85
|
-
}
|
|
86
|
-
case 'inline': {
|
|
87
|
-
const inline_request = new URL(this.api + '/answerInlineQuery');
|
|
88
|
-
const inline_params = new URLSearchParams();
|
|
89
|
-
inline_params.append('inline_query_id', this.update.inline_query?.id.toString() ?? '');
|
|
90
|
-
inline_params.append('results', JSON.stringify([new TelegramInlineQueryResultArticle(message)]));
|
|
91
|
-
console.log(`${inline_request}?${inline_params}`);
|
|
92
|
-
await fetch(`${inline_request}?${inline_params}`);
|
|
93
|
-
break;
|
|
94
|
-
}
|
|
95
|
-
default:
|
|
96
|
-
break;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
class Webhook {
|
|
101
|
-
api;
|
|
102
|
-
webhook;
|
|
103
|
-
constructor(token, request) {
|
|
104
|
-
this.api = new URL('https://api.telegram.org/bot' + token);
|
|
105
|
-
this.webhook = new URL(new URL(request.url).origin + `/${token}`);
|
|
106
|
-
}
|
|
107
|
-
async set() {
|
|
108
|
-
const url = new URL(`${this.api.origin}${this.api.pathname}/setWebhook`);
|
|
109
|
-
const params = url.searchParams;
|
|
110
|
-
params.append('url', this.webhook.toString());
|
|
111
|
-
params.append('max_connections', '100');
|
|
112
|
-
params.append('allowed_updates', JSON.stringify(['message', 'inline_query']));
|
|
113
|
-
params.append('drop_pending_updates', 'true');
|
|
114
|
-
return await fetch(`${url}?${params}`);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { TelegramCommand } from './types';
|
|
2
|
-
export default class TelegramCommands {
|
|
3
|
-
static ping: TelegramCommand;
|
|
4
|
-
static toss: TelegramCommand;
|
|
5
|
-
static epoch: TelegramCommand;
|
|
6
|
-
static kanye: TelegramCommand;
|
|
7
|
-
static bored: TelegramCommand;
|
|
8
|
-
static joke: TelegramCommand;
|
|
9
|
-
static dog: TelegramCommand;
|
|
10
|
-
static roll: TelegramCommand;
|
|
11
|
-
static duckduckgo: TelegramCommand;
|
|
12
|
-
static question: TelegramCommand;
|
|
13
|
-
static sean: TelegramCommand;
|
|
14
|
-
static clear: TelegramCommand;
|
|
15
|
-
static code: TelegramCommand;
|
|
16
|
-
static commandList: TelegramCommand;
|
|
17
|
-
static image: TelegramCommand;
|
|
18
|
-
static translate: TelegramCommand;
|
|
19
|
-
static start: TelegramCommand;
|
|
20
|
-
static ban: TelegramCommand;
|
|
21
|
-
static mute: TelegramCommand;
|
|
22
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export default class TelegramCommands {
|
|
2
|
-
static ping = async (bot, update, args) => bot.ping(bot, update, args);
|
|
3
|
-
static toss = async (bot, update) => bot.toss(bot, update);
|
|
4
|
-
static epoch = async (bot, update) => bot.epoch(bot, update);
|
|
5
|
-
static kanye = async (bot, update) => bot.kanye(bot, update);
|
|
6
|
-
static bored = async (bot, update) => bot.bored(bot, update);
|
|
7
|
-
static joke = async (bot, update) => bot.joke(bot, update);
|
|
8
|
-
static dog = async (bot, update) => bot.dog(bot, update);
|
|
9
|
-
static roll = async (bot, update, args) => bot.roll(bot, update, args);
|
|
10
|
-
static duckduckgo = async (bot, update, args) => bot.duckduckgo(bot, update, args);
|
|
11
|
-
static question = async (bot, update, args) => bot.question(bot, update, args);
|
|
12
|
-
static sean = async (bot, update, args) => bot.sean(bot, update, args);
|
|
13
|
-
static clear = async (bot, update) => bot.clear(bot, update);
|
|
14
|
-
static code = async (bot, update) => bot.code(bot, update);
|
|
15
|
-
static commandList = async (bot, update) => bot.commandList(bot, update);
|
|
16
|
-
static image = async (bot, update, args) => bot.image(bot, update, args);
|
|
17
|
-
static translate = async (bot, update, args) => bot.translate(bot, update, args);
|
|
18
|
-
static start = async (bot, update) => bot.start(bot, update);
|
|
19
|
-
static ban = async (bot, update) => bot.ban(bot, update);
|
|
20
|
-
static mute = async (bot, update) => bot.mute(bot, update);
|
|
21
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/// <reference types="@cloudflare/workers-types" />
|
|
2
|
-
import Webhook from './webhook';
|
|
3
|
-
import { WebhookCommands } from './types';
|
|
4
|
-
export default class TelegramWebhook extends Webhook {
|
|
5
|
-
constructor(api: URL, token: string, url: URL);
|
|
6
|
-
set: (drop_pending_updates?: boolean) => Promise<Response>;
|
|
7
|
-
get: () => Promise<Response>;
|
|
8
|
-
delete: () => Promise<Response>;
|
|
9
|
-
commands: WebhookCommands;
|
|
10
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,17 +0,0 @@
|
|
|
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;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,20 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,20 +0,0 @@
|
|
|
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;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,11 +0,0 @@
|
|
|
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;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,21 +0,0 @@
|
|
|
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;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,5 +0,0 @@
|
|
|
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;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,8 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,43 +0,0 @@
|
|
|
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;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|