@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 CHANGED
@@ -19,7 +19,9 @@ CF Workers Telegram Bot
19
19
  npm i @codebam/cf-workers-telegram-bot
20
20
  ```
21
21
 
22
- See `worker.ts` for an example of what a bot might look like. Just import from `@codebam/cf-workers-telegram-bot`.
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 * as Types from './types';
4
- export { TelegramBot, Types, TelegramExecutionContext };
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 * as Types from './types';
4
- export { TelegramBot, Types, TelegramExecutionContext };
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 API {
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;
@@ -1,4 +1,4 @@
1
- export default class API {
1
+ export default class TelegramApi {
2
2
  static getApiUrl(botApi, slug, data) {
3
3
  const request = new URL(botApi + (slug.startsWith('/') || botApi.endsWith('/') ? '' : '/') + slug);
4
4
  const params = new URLSearchParams();
@@ -1,6 +1,6 @@
1
1
  /// <reference types="@cloudflare/workers-types" />
2
2
  import { TelegramUpdate } from './types';
3
- import TelegramExecutionContext from './ctx';
3
+ import TelegramExecutionContext from './telegram_execution_context';
4
4
  import Webhook from './webhook';
5
5
  export default class TelegramBot {
6
6
  token: string;
@@ -1,5 +1,5 @@
1
1
  import { TelegramUpdate } from './types';
2
- import TelegramExecutionContext from './ctx';
2
+ import TelegramExecutionContext from './telegram_execution_context';
3
3
  import Webhook from './webhook';
4
4
  export default class TelegramBot {
5
5
  token;
@@ -1,4 +1,4 @@
1
- import API from './api';
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 API.sendVideo(this.bot.api.toString(), {
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 API.answerInline(this.bot.api.toString(), {
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 API.getFile(this.bot.api.toString(), { file_id }, this.bot.token);
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 API.sendPhoto(this.bot.api.toString(), {
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 API.sendPhoto(this.bot.api.toString(), {
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 API.answerInline(this.bot.api.toString(), {
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 API.sendMessage(this.bot.api.toString(), {
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 API.sendMessage(this.bot.api.toString(), {
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 API.answerInline(this.bot.api.toString(), {
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 './ctx';
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, API, Webhook, 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, };
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 './ctx';
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, API, Webhook, localhost, WebhookCommands, Update, TelegramUpdate, TelegramInlineQueryResult, TelegramInlineQueryResultPhoto, TelegramInlineQueryResultArticle, };
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.13.0",
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": "b7df0c8cb49e4a36f4c7ab14209e1f91af5f8732"
47
+ "gitHead": "3eafc391582709033358a5ce849933f8da3ffc86"
48
48
  }