@codebam/cf-workers-telegram-bot 5.16.0 → 6.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/main/src/bot_api.d.ts +3 -3
- package/dist/main/src/commands/bored.d.ts +5 -0
- package/dist/main/src/commands/bored.js +8 -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 +2 -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 +8 -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/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/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 +2 -2
- package/dist/main/src/handler.js +5 -7
- package/dist/main/src/libs.js +6 -11
- package/dist/main/src/main.d.ts +11 -11
- package/dist/main/src/main.js +11 -11
- package/dist/main/src/telegram_api.d.ts +3 -3
- package/dist/main/src/telegram_api.js +20 -27
- package/dist/main/src/telegram_bot.d.ts +20 -21
- package/dist/main/src/telegram_bot.js +52 -341
- package/dist/main/src/telegram_commands.d.ts +1 -1
- package/dist/main/src/telegram_commands.js +16 -16
- package/dist/main/src/telegram_webhook.d.ts +2 -2
- package/dist/main/src/telegram_webhook.js +5 -6
- 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/Command.d.ts +5 -0
- package/dist/main/src/types/Command.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/Joke.d.ts +20 -0
- package/dist/main/src/types/Joke.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 +42 -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.d.ts +28 -215
- package/dist/main/src/types.js +10 -113
- package/dist/main/src/webhook.d.ts +1 -1
- package/dist/main/src/webhook.js +3 -4
- package/dist/worker/src/worker.d.ts +1 -1
- package/dist/worker/src/worker.js +37 -37
- package/package.json +4 -7
package/dist/main/src/types.d.ts
CHANGED
|
@@ -1,215 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
export type Joke = {
|
|
30
|
-
error: boolean;
|
|
31
|
-
category: string;
|
|
32
|
-
type: string;
|
|
33
|
-
setup?: string;
|
|
34
|
-
delivery?: string;
|
|
35
|
-
joke?: string;
|
|
36
|
-
flags: {
|
|
37
|
-
nsfw: boolean;
|
|
38
|
-
religious: boolean;
|
|
39
|
-
political: boolean;
|
|
40
|
-
racist: boolean;
|
|
41
|
-
sexist: boolean;
|
|
42
|
-
explicit: boolean;
|
|
43
|
-
};
|
|
44
|
-
id: number;
|
|
45
|
-
safe: boolean;
|
|
46
|
-
lang: string;
|
|
47
|
-
};
|
|
48
|
-
export type Bored = {
|
|
49
|
-
activity: string;
|
|
50
|
-
type: string;
|
|
51
|
-
participants: number;
|
|
52
|
-
price: number;
|
|
53
|
-
link: string;
|
|
54
|
-
key: string;
|
|
55
|
-
accessibility: 0;
|
|
56
|
-
};
|
|
57
|
-
export type Balance = Record<string, {
|
|
58
|
-
final_balance: number;
|
|
59
|
-
n_tx: number;
|
|
60
|
-
total_received: number;
|
|
61
|
-
}>;
|
|
62
|
-
export type TelegramFrom = {
|
|
63
|
-
first_name: string;
|
|
64
|
-
id: number;
|
|
65
|
-
is_bot: boolean;
|
|
66
|
-
language_code: string;
|
|
67
|
-
username: string;
|
|
68
|
-
};
|
|
69
|
-
export type TelegramChat = {
|
|
70
|
-
id: number;
|
|
71
|
-
type: string;
|
|
72
|
-
title?: string;
|
|
73
|
-
username?: string;
|
|
74
|
-
first_name?: string;
|
|
75
|
-
last_name?: string;
|
|
76
|
-
bio?: string;
|
|
77
|
-
has_private_forwards: boolean;
|
|
78
|
-
description?: string;
|
|
79
|
-
invite_link?: string;
|
|
80
|
-
pinned_message?: TelegramMessage;
|
|
81
|
-
slow_mode_delay?: number;
|
|
82
|
-
message_auto_delete_time?: number;
|
|
83
|
-
has_protected_content?: boolean;
|
|
84
|
-
sticker_set_name?: string;
|
|
85
|
-
can_set_sticker_set?: boolean;
|
|
86
|
-
linked_chat_id?: number;
|
|
87
|
-
};
|
|
88
|
-
export type TelegramUser = {
|
|
89
|
-
id: number;
|
|
90
|
-
is_bot: boolean;
|
|
91
|
-
first_name: string;
|
|
92
|
-
last_name?: string;
|
|
93
|
-
username?: string;
|
|
94
|
-
language_code?: string;
|
|
95
|
-
can_join_groups?: boolean;
|
|
96
|
-
can_read_all_group_messages?: boolean;
|
|
97
|
-
supports_inline_queries: boolean;
|
|
98
|
-
};
|
|
99
|
-
export type TelegramMessageEntity = {
|
|
100
|
-
type: string;
|
|
101
|
-
offset: number;
|
|
102
|
-
length: number;
|
|
103
|
-
url?: string;
|
|
104
|
-
user?: TelegramUser;
|
|
105
|
-
language?: string;
|
|
106
|
-
};
|
|
107
|
-
export type TelegramPhotoSize = {
|
|
108
|
-
file_id: string;
|
|
109
|
-
file_unique_id: string;
|
|
110
|
-
width: number;
|
|
111
|
-
height: number;
|
|
112
|
-
file_size?: number;
|
|
113
|
-
};
|
|
114
|
-
export type TelegramMessage = {
|
|
115
|
-
message_id: number;
|
|
116
|
-
from: TelegramFrom;
|
|
117
|
-
sender_chat?: TelegramChat;
|
|
118
|
-
date: number;
|
|
119
|
-
chat: TelegramChat;
|
|
120
|
-
forward_from?: TelegramUser;
|
|
121
|
-
forward_from_chat?: TelegramChat;
|
|
122
|
-
forward_from_message_id?: number;
|
|
123
|
-
forward_signature?: string;
|
|
124
|
-
forward_sender_name?: string;
|
|
125
|
-
forward_date?: number;
|
|
126
|
-
is_automatic_forward?: boolean;
|
|
127
|
-
reply_to_message?: TelegramMessage;
|
|
128
|
-
via_bot?: TelegramUser;
|
|
129
|
-
edit_date?: number;
|
|
130
|
-
has_protected_content?: boolean;
|
|
131
|
-
media_group_id?: string;
|
|
132
|
-
author_signature?: string;
|
|
133
|
-
text?: string;
|
|
134
|
-
entities?: TelegramMessageEntity[];
|
|
135
|
-
photo?: TelegramPhotoSize[];
|
|
136
|
-
caption?: string;
|
|
137
|
-
caption_entities?: TelegramMessageEntity[];
|
|
138
|
-
new_chat_members?: TelegramUser[];
|
|
139
|
-
left_chat_member?: TelegramUser;
|
|
140
|
-
new_chat_title?: string;
|
|
141
|
-
delete_chat_photo?: boolean;
|
|
142
|
-
group_chat_created?: boolean;
|
|
143
|
-
supergroup_chat_created?: boolean;
|
|
144
|
-
channel_chat_created?: boolean;
|
|
145
|
-
migrate_to_chat_id?: number;
|
|
146
|
-
migrate_from_chat_id?: number;
|
|
147
|
-
pinned_message?: TelegramMessage;
|
|
148
|
-
connected_website?: string;
|
|
149
|
-
};
|
|
150
|
-
export type TelegramInputMessageContent = {
|
|
151
|
-
message_text: string;
|
|
152
|
-
parse_mode: string;
|
|
153
|
-
};
|
|
154
|
-
export type TelegramInlineQuery = {
|
|
155
|
-
chat_type: "sender" | "private" | "group" | "supergroup" | "channel";
|
|
156
|
-
from: TelegramFrom;
|
|
157
|
-
id: number;
|
|
158
|
-
offset: string;
|
|
159
|
-
query: string;
|
|
160
|
-
};
|
|
161
|
-
export declare class Update {
|
|
162
|
-
[key: string]: unknown;
|
|
163
|
-
}
|
|
164
|
-
export declare class TelegramUpdate extends Update {
|
|
165
|
-
update_id: number;
|
|
166
|
-
message?: TelegramMessage;
|
|
167
|
-
edited_message?: TelegramMessage;
|
|
168
|
-
channel_post?: TelegramMessage;
|
|
169
|
-
edited_channel_post?: TelegramMessage;
|
|
170
|
-
inline_query?: TelegramInlineQuery;
|
|
171
|
-
constructor(update: PartialTelegramUpdate);
|
|
172
|
-
}
|
|
173
|
-
export type PartialTelegramUpdate = {
|
|
174
|
-
update_id?: number;
|
|
175
|
-
message?: TelegramMessage;
|
|
176
|
-
edited_message?: TelegramMessage;
|
|
177
|
-
channel_post?: TelegramMessage;
|
|
178
|
-
edited_channel_post?: TelegramMessage;
|
|
179
|
-
inline_query?: TelegramInlineQuery;
|
|
180
|
-
};
|
|
181
|
-
export type TelegramInlineQueryType = "article" | "photo" | "gif" | "mpeg4_gif" | "video" | "audio" | "voice" | "document" | "location" | "venue" | "contact" | "game" | "sticker";
|
|
182
|
-
export declare class TelegramInlineQueryResult {
|
|
183
|
-
type: TelegramInlineQueryType;
|
|
184
|
-
id: string;
|
|
185
|
-
constructor(type: TelegramInlineQueryType);
|
|
186
|
-
}
|
|
187
|
-
export declare class TelegramInlineQueryResultPhoto extends TelegramInlineQueryResult {
|
|
188
|
-
photo_url: string;
|
|
189
|
-
thumb_url: string;
|
|
190
|
-
photo_width?: number;
|
|
191
|
-
photo_height?: number;
|
|
192
|
-
title?: string;
|
|
193
|
-
description?: string;
|
|
194
|
-
caption?: string;
|
|
195
|
-
parse_mode?: string;
|
|
196
|
-
caption_entities?: string;
|
|
197
|
-
constructor(photo: string);
|
|
198
|
-
}
|
|
199
|
-
export declare class TelegramInlineQueryResultArticle extends TelegramInlineQueryResult {
|
|
200
|
-
title: string;
|
|
201
|
-
input_message_content: TelegramInputMessageContent;
|
|
202
|
-
thumb_url: string;
|
|
203
|
-
constructor(content: string, title?: string, parse_mode?: string, thumb_url?: string);
|
|
204
|
-
}
|
|
205
|
-
export type DDGQueryResponse = {
|
|
206
|
-
AbstractSource: string;
|
|
207
|
-
AbstractURL: string;
|
|
208
|
-
Redirect: string;
|
|
209
|
-
Image: string;
|
|
210
|
-
RelatedTopics: {
|
|
211
|
-
Icon: {
|
|
212
|
-
URL: string;
|
|
213
|
-
};
|
|
214
|
-
}[];
|
|
215
|
-
};
|
|
1
|
+
import Webhook from './webhook';
|
|
2
|
+
import Command from './types/Command';
|
|
3
|
+
import TelegramCommand from './types/TelegramCommand';
|
|
4
|
+
import Commands from './types/Commands';
|
|
5
|
+
import Kv from './types/Kv';
|
|
6
|
+
import Config from './types/Config';
|
|
7
|
+
import localhost from './types/localhost';
|
|
8
|
+
import WebhookCommands from './types/WebhookCommands';
|
|
9
|
+
import Joke from './types/Joke';
|
|
10
|
+
import Bored from './types/Bored';
|
|
11
|
+
import Balance from './types/Balance';
|
|
12
|
+
import TelegramFrom from './types/TelegramFrom';
|
|
13
|
+
import TelegramChat from './types/TelegramChat';
|
|
14
|
+
import TelegramUser from './types/TelegramUser';
|
|
15
|
+
import TelegramMessageEntity from './types/TelegramMessageEntity';
|
|
16
|
+
import TelegramPhotoSize from './types/TelegramPhotoSize';
|
|
17
|
+
import TelegramMessage from './types/TelegramMessage';
|
|
18
|
+
import TelegramInputMessageContent from './types/TelegramInputMessageContent';
|
|
19
|
+
import TelegramInlineQuery from './types/TelegramInlineQuery';
|
|
20
|
+
import Update from './types/Update';
|
|
21
|
+
import TelegramUpdate from './types/TelegramUpdate';
|
|
22
|
+
import PartialTelegramUpdate from './types/PartialTelegramUpdate';
|
|
23
|
+
import TelegramInlineQueryType from './types/TelegramInlineQueryType';
|
|
24
|
+
import TelegramInlineQueryResult from './types/TelegramInlineQueryResult';
|
|
25
|
+
import TelegramInlineQueryResultPhoto from './types/TelegramInlineQueryResultPhoto';
|
|
26
|
+
import TelegramInlineQueryResultArticle from './types/TelegramInlineQueryResultArticle';
|
|
27
|
+
import DDGQueryResponse from './types/DDGQueryResponse';
|
|
28
|
+
export { Webhook, Command, TelegramCommand, Commands, Kv, Config, localhost, WebhookCommands, Joke, Bored, Balance, TelegramFrom, TelegramChat, TelegramUser, TelegramMessageEntity, TelegramPhotoSize, TelegramMessage, TelegramInputMessageContent, TelegramInlineQuery, Update, TelegramUpdate, PartialTelegramUpdate, TelegramInlineQueryType, TelegramInlineQueryResult, TelegramInlineQueryResultPhoto, TelegramInlineQueryResultArticle, DDGQueryResponse, };
|
package/dist/main/src/types.js
CHANGED
|
@@ -1,113 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
}
|
|
34
|
-
export const localhost = new URL("http://localhost");
|
|
35
|
-
export class WebhookCommands {
|
|
36
|
-
}
|
|
37
|
-
export class Update {
|
|
38
|
-
}
|
|
39
|
-
export class TelegramUpdate extends Update {
|
|
40
|
-
update_id;
|
|
41
|
-
message;
|
|
42
|
-
edited_message;
|
|
43
|
-
channel_post;
|
|
44
|
-
edited_channel_post;
|
|
45
|
-
inline_query;
|
|
46
|
-
// chosen_inline_result?: TelegramChosenInlineResult;
|
|
47
|
-
// callback_query?: TelegramCallbackQuery;
|
|
48
|
-
// shipping_query?: TelegramShippingQuery;
|
|
49
|
-
// pre_checkout_query?: TelegramPreCheckoutQuery;
|
|
50
|
-
// poll?: TelegramPoll;
|
|
51
|
-
// poll_answer?: TelegramPollAnswer;
|
|
52
|
-
// my_chat_member?: TelegramChatMemberUpdated;
|
|
53
|
-
// chat_member?: TelegramChatMemberUpdated;
|
|
54
|
-
// chat_join_request: TelegramChatJoinRequest;
|
|
55
|
-
constructor(update) {
|
|
56
|
-
super();
|
|
57
|
-
this.update_id = update.update_id || 0;
|
|
58
|
-
this.message = update.message;
|
|
59
|
-
this.edited_message = update.edited_message;
|
|
60
|
-
this.channel_post = update.channel_post;
|
|
61
|
-
this.edited_channel_post = update.edited_channel_post;
|
|
62
|
-
this.inline_query = update.inline_query;
|
|
63
|
-
// chosen_inline_result = update.chosen_inline_result;
|
|
64
|
-
// callback_query = update.callback_query;
|
|
65
|
-
// shipping_query = update.shipping_query;
|
|
66
|
-
// pre_checkout_query = update.pre_checkout_query;
|
|
67
|
-
// poll = update.poll;
|
|
68
|
-
// poll_answer = update.poll_answer;
|
|
69
|
-
// my_chat_member = update.my_chat_member;
|
|
70
|
-
// chat_member = update.chat_member;
|
|
71
|
-
// chat_join_request = update.chat_join_request;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
export class TelegramInlineQueryResult {
|
|
75
|
-
type;
|
|
76
|
-
id;
|
|
77
|
-
constructor(type) {
|
|
78
|
-
this.type = type;
|
|
79
|
-
this.id = crypto.randomUUID();
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
export class TelegramInlineQueryResultPhoto extends TelegramInlineQueryResult {
|
|
83
|
-
photo_url; // must be a jpg
|
|
84
|
-
thumb_url;
|
|
85
|
-
photo_width;
|
|
86
|
-
photo_height;
|
|
87
|
-
title;
|
|
88
|
-
description;
|
|
89
|
-
caption;
|
|
90
|
-
parse_mode;
|
|
91
|
-
caption_entities;
|
|
92
|
-
// reply_markup?: TelegramInlineKeyboardMarkup;
|
|
93
|
-
// input_message_content?: TelegramInputMessageContent;
|
|
94
|
-
constructor(photo) {
|
|
95
|
-
super("photo");
|
|
96
|
-
this.photo_url = photo;
|
|
97
|
-
this.thumb_url = photo;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
export class TelegramInlineQueryResultArticle extends TelegramInlineQueryResult {
|
|
101
|
-
title;
|
|
102
|
-
input_message_content;
|
|
103
|
-
thumb_url;
|
|
104
|
-
constructor(content, title = content, parse_mode = "", thumb_url = "") {
|
|
105
|
-
super("article");
|
|
106
|
-
this.title = title;
|
|
107
|
-
this.input_message_content = {
|
|
108
|
-
message_text: content.toString(),
|
|
109
|
-
parse_mode,
|
|
110
|
-
};
|
|
111
|
-
this.thumb_url = thumb_url;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
1
|
+
import Webhook from './webhook';
|
|
2
|
+
import Config from './types/Config';
|
|
3
|
+
import localhost from './types/localhost';
|
|
4
|
+
import WebhookCommands from './types/WebhookCommands';
|
|
5
|
+
import Update from './types/Update';
|
|
6
|
+
import TelegramUpdate from './types/TelegramUpdate';
|
|
7
|
+
import TelegramInlineQueryResult from './types/TelegramInlineQueryResult';
|
|
8
|
+
import TelegramInlineQueryResultPhoto from './types/TelegramInlineQueryResultPhoto';
|
|
9
|
+
import TelegramInlineQueryResultArticle from './types/TelegramInlineQueryResultArticle';
|
|
10
|
+
export { Webhook, Config, localhost, WebhookCommands, Update, TelegramUpdate, TelegramInlineQueryResult, TelegramInlineQueryResultPhoto, TelegramInlineQueryResultArticle, };
|
package/dist/main/src/webhook.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { JSONResponse } from
|
|
1
|
+
import { JSONResponse } from './libs';
|
|
2
2
|
export default class Webhook {
|
|
3
3
|
api;
|
|
4
4
|
token;
|
|
@@ -9,9 +9,8 @@ export default class Webhook {
|
|
|
9
9
|
this.token = token;
|
|
10
10
|
this.url = url;
|
|
11
11
|
this.commands = {
|
|
12
|
-
default: () => new Promise(() => JSONResponse({ error:
|
|
12
|
+
default: () => new Promise(() => JSONResponse({ error: 'Invalid command' }, 400)),
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
|
-
process = async (url) => this.commands[url.searchParams.get(
|
|
16
|
-
this.commands.default;
|
|
15
|
+
process = async (url) => this.commands[url.searchParams.get('command') ?? '']?.() ?? this.commands.default;
|
|
17
16
|
}
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import { TelegramCommands, Handler, TelegramWebhook, TelegramBot
|
|
1
|
+
import { TelegramCommands, Handler, TelegramWebhook, TelegramBot } from '../../main/src/main';
|
|
2
2
|
export default {
|
|
3
3
|
fetch: async (request, env) => new Handler([
|
|
4
4
|
{
|
|
5
|
-
bot_name:
|
|
5
|
+
bot_name: '@TuxRobot',
|
|
6
6
|
api: TelegramBot,
|
|
7
7
|
webhook: new TelegramWebhook(new URL(`https://api.telegram.org/bot${env.SECRET_TELEGRAM_API_TOKEN}`), env.SECRET_TELEGRAM_API_TOKEN, new URL(new URL(request.url).origin)),
|
|
8
8
|
commands: {
|
|
9
9
|
default: TelegramCommands.question,
|
|
10
10
|
inline: TelegramCommands.question,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
11
|
+
'/ping': TelegramCommands.ping,
|
|
12
|
+
'/toss': TelegramCommands.toss,
|
|
13
|
+
'/epoch': TelegramCommands.epoch,
|
|
14
|
+
'/kanye': TelegramCommands.kanye,
|
|
15
|
+
'/bored': TelegramCommands.bored,
|
|
16
|
+
'/joke': TelegramCommands.joke,
|
|
17
|
+
'/dog': TelegramCommands.dog,
|
|
18
|
+
'/roll': TelegramCommands.roll,
|
|
19
|
+
'/duckduckgo': TelegramCommands.duckduckgo,
|
|
20
|
+
'/code': TelegramCommands.code,
|
|
21
|
+
'/commands': TelegramCommands.commandList,
|
|
22
|
+
'/question': TelegramCommands.question,
|
|
23
|
+
'/clear': TelegramCommands.clear,
|
|
24
|
+
'/help': TelegramCommands.commandList,
|
|
25
|
+
'/image': TelegramCommands.image,
|
|
26
|
+
'/start': TelegramCommands.question,
|
|
27
27
|
},
|
|
28
28
|
kv: { get_set: env.KV_GET_SET, uid_data: env.KV_UID_DATA },
|
|
29
29
|
ai: env.AI,
|
|
@@ -32,59 +32,59 @@ export default {
|
|
|
32
32
|
chat_model: env.CHAT_MODEL,
|
|
33
33
|
},
|
|
34
34
|
{
|
|
35
|
-
bot_name:
|
|
35
|
+
bot_name: '@duckduckbot',
|
|
36
36
|
api: TelegramBot,
|
|
37
37
|
webhook: new TelegramWebhook(new URL(`https://api.telegram.org/bot${env.SECRET_TELEGRAM_API_TOKEN2}`), env.SECRET_TELEGRAM_API_TOKEN2, new URL(new URL(request.url).origin)),
|
|
38
38
|
commands: {
|
|
39
39
|
default: TelegramCommands.duckduckgo,
|
|
40
40
|
inline: TelegramCommands.duckduckgo, // default inline response
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
41
|
+
'/duckduckgo': TelegramCommands.duckduckgo,
|
|
42
|
+
'/question': TelegramCommands.question,
|
|
43
|
+
'/code': TelegramCommands.code,
|
|
44
|
+
'/commands': TelegramCommands.commandList,
|
|
45
|
+
'/help': TelegramCommands.commandList,
|
|
46
|
+
'/start': TelegramCommands.commandList,
|
|
47
47
|
},
|
|
48
48
|
ai: env.AI,
|
|
49
49
|
db: env.DB,
|
|
50
50
|
},
|
|
51
51
|
{
|
|
52
|
-
bot_name:
|
|
52
|
+
bot_name: '@ddggbot',
|
|
53
53
|
api: TelegramBot,
|
|
54
54
|
webhook: new TelegramWebhook(new URL(`https://api.telegram.org/bot${env.SECRET_TELEGRAM_API_TOKEN3}`), env.SECRET_TELEGRAM_API_TOKEN3, new URL(new URL(request.url).origin)),
|
|
55
55
|
commands: {
|
|
56
56
|
default: TelegramCommands.duckduckgo,
|
|
57
57
|
inline: TelegramCommands.duckduckgo,
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
58
|
+
'/duckduckgo': TelegramCommands.duckduckgo,
|
|
59
|
+
'/question': TelegramCommands.question,
|
|
60
|
+
'/code': TelegramCommands.code,
|
|
61
|
+
'/commands': TelegramCommands.commandList,
|
|
62
|
+
'/help': TelegramCommands.commandList,
|
|
63
|
+
'/start': TelegramCommands.commandList,
|
|
64
64
|
},
|
|
65
65
|
ai: env.AI,
|
|
66
66
|
db: env.DB,
|
|
67
67
|
},
|
|
68
68
|
{
|
|
69
|
-
bot_name:
|
|
69
|
+
bot_name: '@SeanB_robot',
|
|
70
70
|
api: TelegramBot,
|
|
71
71
|
webhook: new TelegramWebhook(new URL(`https://api.telegram.org/bot${env.SECRET_TELEGRAM_API_TOKEN4}`), env.SECRET_TELEGRAM_API_TOKEN4, new URL(new URL(request.url).origin)),
|
|
72
72
|
commands: {
|
|
73
73
|
default: TelegramCommands.sean,
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
'/clear': TelegramCommands.clear,
|
|
75
|
+
'/start': TelegramCommands.commandList,
|
|
76
76
|
},
|
|
77
77
|
ai: env.AI,
|
|
78
78
|
db: env.DB,
|
|
79
79
|
},
|
|
80
80
|
{
|
|
81
|
-
bot_name:
|
|
81
|
+
bot_name: '@TranslatePartyBot',
|
|
82
82
|
api: TelegramBot,
|
|
83
83
|
webhook: new TelegramWebhook(new URL(`https://api.telegram.org/bot${env.SECRET_TELEGRAM_API_TOKEN5}`), env.SECRET_TELEGRAM_API_TOKEN5, new URL(new URL(request.url).origin)),
|
|
84
84
|
commands: {
|
|
85
85
|
default: TelegramCommands.translate,
|
|
86
86
|
inline: TelegramCommands.translate,
|
|
87
|
-
|
|
87
|
+
'/start': TelegramCommands.commandList,
|
|
88
88
|
},
|
|
89
89
|
ai: env.AI,
|
|
90
90
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codebam/cf-workers-telegram-bot",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.1.0",
|
|
4
4
|
"description": "serverless telegram bot on cf workers",
|
|
5
5
|
"main": "./dist/main/src/main.js",
|
|
6
6
|
"module": "./dist/main/src/main.js",
|
|
@@ -30,10 +30,10 @@
|
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@cloudflare/workers-types": "^4.20240502.0",
|
|
33
|
-
"@eslint/js": "^9.
|
|
33
|
+
"@eslint/js": "^9.2.0",
|
|
34
34
|
"@typescript-eslint/eslint-plugin": "^7.8.0",
|
|
35
35
|
"@typescript-eslint/parser": "^7.8.0",
|
|
36
|
-
"eslint": "^
|
|
36
|
+
"eslint": "^9.2.0",
|
|
37
37
|
"eslint-config-prettier": "^9.1.0",
|
|
38
38
|
"globals": "^15.1.0",
|
|
39
39
|
"lerna": "^8.1.2",
|
|
@@ -41,8 +41,5 @@
|
|
|
41
41
|
"typescript": "^5.4.5",
|
|
42
42
|
"typescript-eslint": "^7.8.0"
|
|
43
43
|
},
|
|
44
|
-
"
|
|
45
|
-
"@cloudflare/ai": "1.0.53"
|
|
46
|
-
},
|
|
47
|
-
"gitHead": "fb3449a1162c24d725a1cde10ea9a5b3fde0fba0"
|
|
44
|
+
"gitHead": "0f3db27086c56ef9d50370c217ed09b5d5b3d401"
|
|
48
45
|
}
|