@codebam/cf-workers-telegram-bot 7.13.0 → 7.15.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/README.md +3 -1
- package/dist/main.d.ts +31 -3
- package/dist/main.js +12 -3
- package/dist/{api.d.ts → telegram_api.d.ts} +1 -1
- package/dist/{api.js → telegram_api.js} +1 -1
- package/dist/telegram_bot.d.ts +1 -1
- package/dist/telegram_bot.js +1 -1
- package/dist/{ctx.js → telegram_execution_context.js} +10 -10
- package/dist/types.d.ts +3 -3
- package/dist/types.js +3 -3
- package/package.json +2 -2
- /package/dist/{ctx.d.ts → telegram_execution_context.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -19,7 +19,9 @@ CF Workers Telegram Bot
|
|
|
19
19
|
npm i @codebam/cf-workers-telegram-bot
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
-
See
|
|
22
|
+
See [cwtb-consumer](https://github.com/codebam/cwtb-consumer) for an example of what a bot might look like. Just import from `@codebam/cf-workers-telegram-bot`.
|
|
23
|
+
|
|
24
|
+
See [my blog post](https://seanbehan.ca/posts/cf-workers-telegram-bot) for a more in-depth guide for how to set up a bot.
|
|
23
25
|
|
|
24
26
|
- `npm create cloudflare@latest`
|
|
25
27
|
- `npx wrangler login`
|
package/dist/main.d.ts
CHANGED
|
@@ -1,4 +1,32 @@
|
|
|
1
|
-
import TelegramExecutionContext from './ctx';
|
|
2
1
|
import TelegramBot from './telegram_bot';
|
|
3
|
-
import
|
|
4
|
-
|
|
2
|
+
import TelegramExecutionContext from './telegram_execution_context';
|
|
3
|
+
import Webhook from './webhook';
|
|
4
|
+
import TelegramApi from './telegram_api';
|
|
5
|
+
import TelegramCommand from './types/TelegramCommand';
|
|
6
|
+
import Kv from './types/Kv';
|
|
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
|
+
import ChatPermissions from './types/ChatPermissions';
|
|
29
|
+
import Kanye from './types/Kanye';
|
|
30
|
+
import SerializableData from './types/SerializableData';
|
|
31
|
+
export default TelegramBot;
|
|
32
|
+
export { TelegramBot, TelegramExecutionContext, Webhook, TelegramApi, 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, SerializableData, };
|
package/dist/main.js
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
|
-
import TelegramExecutionContext from './ctx';
|
|
2
1
|
import TelegramBot from './telegram_bot';
|
|
3
|
-
import
|
|
4
|
-
|
|
2
|
+
import TelegramExecutionContext from './telegram_execution_context';
|
|
3
|
+
import Webhook from './webhook';
|
|
4
|
+
import TelegramApi from './telegram_api';
|
|
5
|
+
import localhost from './types/localhost';
|
|
6
|
+
import WebhookCommands from './types/WebhookCommands';
|
|
7
|
+
import Update from './types/Update';
|
|
8
|
+
import TelegramUpdate from './types/TelegramUpdate';
|
|
9
|
+
import TelegramInlineQueryResult from './types/TelegramInlineQueryResult';
|
|
10
|
+
import TelegramInlineQueryResultPhoto from './types/TelegramInlineQueryResultPhoto';
|
|
11
|
+
import TelegramInlineQueryResultArticle from './types/TelegramInlineQueryResultArticle';
|
|
12
|
+
export default TelegramBot;
|
|
13
|
+
export { TelegramBot, TelegramExecutionContext, Webhook, TelegramApi, localhost, WebhookCommands, Update, TelegramUpdate, TelegramInlineQueryResult, TelegramInlineQueryResultPhoto, TelegramInlineQueryResultArticle, };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="@cloudflare/workers-types" />
|
|
2
2
|
import { SerializableData, TelegramInlineQueryResultArticle, TelegramInlineQueryResultPhoto } from './types';
|
|
3
3
|
import TelegramInlineQueryResultVideo from './types/TelegramInlineQueryResultVideo';
|
|
4
|
-
export default class
|
|
4
|
+
export default class TelegramApi {
|
|
5
5
|
static getApiUrl(botApi: string, slug: string, data: Record<string, SerializableData>): Request<unknown, CfProperties<unknown>>;
|
|
6
6
|
static getFile(botApi: string, data: {
|
|
7
7
|
file_id: string;
|
package/dist/telegram_bot.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="@cloudflare/workers-types" />
|
|
2
2
|
import { TelegramUpdate } from './types';
|
|
3
|
-
import TelegramExecutionContext from './
|
|
3
|
+
import TelegramExecutionContext from './telegram_execution_context';
|
|
4
4
|
import Webhook from './webhook';
|
|
5
5
|
export default class TelegramBot {
|
|
6
6
|
token: string;
|
package/dist/telegram_bot.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import TelegramApi from './telegram_api';
|
|
2
2
|
import { TelegramInlineQueryResultArticle, TelegramInlineQueryResultPhoto } from './types';
|
|
3
3
|
import TelegramInlineQueryResultVideo from './types/TelegramInlineQueryResultVideo';
|
|
4
4
|
export default class TelegramExecutionContext {
|
|
@@ -39,13 +39,13 @@ export default class TelegramExecutionContext {
|
|
|
39
39
|
async replyVideo(video) {
|
|
40
40
|
switch (this.update_type) {
|
|
41
41
|
case 'message':
|
|
42
|
-
return await
|
|
42
|
+
return await TelegramApi.sendVideo(this.bot.api.toString(), {
|
|
43
43
|
chat_id: this.update.message?.chat.id.toString() ?? '',
|
|
44
44
|
reply_to_message_id: this.update.message?.message_id.toString() ?? '',
|
|
45
45
|
video,
|
|
46
46
|
});
|
|
47
47
|
case 'inline':
|
|
48
|
-
return await
|
|
48
|
+
return await TelegramApi.answerInline(this.bot.api.toString(), {
|
|
49
49
|
inline_query_id: this.update.inline_query?.id.toString() ?? '',
|
|
50
50
|
results: [new TelegramInlineQueryResultVideo(video)],
|
|
51
51
|
});
|
|
@@ -54,26 +54,26 @@ export default class TelegramExecutionContext {
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
async getFile(file_id) {
|
|
57
|
-
return await
|
|
57
|
+
return await TelegramApi.getFile(this.bot.api.toString(), { file_id }, this.bot.token);
|
|
58
58
|
}
|
|
59
59
|
async replyPhoto(photo, caption = '') {
|
|
60
60
|
switch (this.update_type) {
|
|
61
61
|
case 'photo':
|
|
62
|
-
return await
|
|
62
|
+
return await TelegramApi.sendPhoto(this.bot.api.toString(), {
|
|
63
63
|
chat_id: this.update.message?.chat.id.toString() ?? '',
|
|
64
64
|
reply_to_message_id: this.update.message?.message_id.toString() ?? '',
|
|
65
65
|
photo,
|
|
66
66
|
caption,
|
|
67
67
|
});
|
|
68
68
|
case 'message':
|
|
69
|
-
return await
|
|
69
|
+
return await TelegramApi.sendPhoto(this.bot.api.toString(), {
|
|
70
70
|
chat_id: this.update.message?.chat.id.toString() ?? '',
|
|
71
71
|
reply_to_message_id: this.update.message?.message_id.toString() ?? '',
|
|
72
72
|
photo,
|
|
73
73
|
caption,
|
|
74
74
|
});
|
|
75
75
|
case 'inline':
|
|
76
|
-
return await
|
|
76
|
+
return await TelegramApi.answerInline(this.bot.api.toString(), {
|
|
77
77
|
inline_query_id: this.update.inline_query?.id.toString() ?? '',
|
|
78
78
|
results: [new TelegramInlineQueryResultPhoto(photo)],
|
|
79
79
|
});
|
|
@@ -84,21 +84,21 @@ export default class TelegramExecutionContext {
|
|
|
84
84
|
async reply(message, parse_mode = '') {
|
|
85
85
|
switch (this.update_type) {
|
|
86
86
|
case 'message':
|
|
87
|
-
return await
|
|
87
|
+
return await TelegramApi.sendMessage(this.bot.api.toString(), {
|
|
88
88
|
chat_id: this.update.message?.chat.id.toString() ?? '',
|
|
89
89
|
reply_to_message_id: this.update.message?.message_id.toString() ?? '',
|
|
90
90
|
text: message,
|
|
91
91
|
parse_mode,
|
|
92
92
|
});
|
|
93
93
|
case 'photo':
|
|
94
|
-
return await
|
|
94
|
+
return await TelegramApi.sendMessage(this.bot.api.toString(), {
|
|
95
95
|
chat_id: this.update.message?.chat.id.toString() ?? '',
|
|
96
96
|
reply_to_message_id: this.update.message?.message_id.toString() ?? '',
|
|
97
97
|
text: message,
|
|
98
98
|
parse_mode,
|
|
99
99
|
});
|
|
100
100
|
case 'inline':
|
|
101
|
-
return await
|
|
101
|
+
return await TelegramApi.answerInline(this.bot.api.toString(), {
|
|
102
102
|
inline_query_id: this.update.inline_query?.id.toString() ?? '',
|
|
103
103
|
results: [new TelegramInlineQueryResultArticle(message)],
|
|
104
104
|
});
|
package/dist/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import TelegramBot from './telegram_bot';
|
|
2
|
-
import TelegramExecutionContext from './
|
|
3
|
-
import API from './api';
|
|
2
|
+
import TelegramExecutionContext from './telegram_execution_context';
|
|
4
3
|
import Webhook from './webhook';
|
|
4
|
+
import TelegramApi from './telegram_api';
|
|
5
5
|
import TelegramCommand from './types/TelegramCommand';
|
|
6
6
|
import Kv from './types/Kv';
|
|
7
7
|
import localhost from './types/localhost';
|
|
@@ -29,4 +29,4 @@ import ChatPermissions from './types/ChatPermissions';
|
|
|
29
29
|
import Kanye from './types/Kanye';
|
|
30
30
|
import SerializableData from './types/SerializableData';
|
|
31
31
|
export default TelegramBot;
|
|
32
|
-
export { TelegramBot, TelegramExecutionContext,
|
|
32
|
+
export { TelegramBot, TelegramExecutionContext, Webhook, TelegramApi, 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, SerializableData, };
|
package/dist/types.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import TelegramBot from './telegram_bot';
|
|
2
|
-
import TelegramExecutionContext from './
|
|
3
|
-
import API from './api';
|
|
2
|
+
import TelegramExecutionContext from './telegram_execution_context';
|
|
4
3
|
import Webhook from './webhook';
|
|
4
|
+
import TelegramApi from './telegram_api';
|
|
5
5
|
import localhost from './types/localhost';
|
|
6
6
|
import WebhookCommands from './types/WebhookCommands';
|
|
7
7
|
import Update from './types/Update';
|
|
@@ -10,4 +10,4 @@ import TelegramInlineQueryResult from './types/TelegramInlineQueryResult';
|
|
|
10
10
|
import TelegramInlineQueryResultPhoto from './types/TelegramInlineQueryResultPhoto';
|
|
11
11
|
import TelegramInlineQueryResultArticle from './types/TelegramInlineQueryResultArticle';
|
|
12
12
|
export default TelegramBot;
|
|
13
|
-
export { TelegramBot, TelegramExecutionContext,
|
|
13
|
+
export { TelegramBot, TelegramExecutionContext, Webhook, TelegramApi, localhost, WebhookCommands, Update, TelegramUpdate, TelegramInlineQueryResult, TelegramInlineQueryResultPhoto, TelegramInlineQueryResultArticle, };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codebam/cf-workers-telegram-bot",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.15.0",
|
|
4
4
|
"description": "serverless telegram bot on cf workers",
|
|
5
5
|
"main": "./dist/main.js",
|
|
6
6
|
"module": "./dist/main.js",
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"typescript-eslint": "^7.8.0",
|
|
45
45
|
"vitest": "^1.6.0"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "3eafc391582709033358a5ce849933f8da3ffc86"
|
|
48
48
|
}
|
|
File without changes
|