@effect-ak/tg-bot-client 0.5.3 → 0.6.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.
@@ -0,0 +1,391 @@
1
+ type BindOrUnbindEventHandler = <K extends keyof EventHandlers>(eventName: K, handler: EventHandlers[K]) => void;
2
+ type EventHandlers = {
3
+ activated: () => void;
4
+ deactivated: () => void;
5
+ themeChanged: () => void;
6
+ viewportChanged: (options: {
7
+ isStateStable: boolean;
8
+ }) => void;
9
+ safeAreaChanged: () => void;
10
+ contentSafeAreaChanged: () => void;
11
+ mainButtonClicked: () => void;
12
+ backButtonClicked: () => void;
13
+ settingsButtonClicked: () => void;
14
+ invoiceClosed: (options: {
15
+ url: string;
16
+ status: "paid" | "cancelled" | "failed" | "pending";
17
+ }) => void;
18
+ popupClosed: (options: {
19
+ button_id: string | null;
20
+ }) => void;
21
+ qrTextReceived: (options: {
22
+ data: string;
23
+ }) => void;
24
+ scanQrPopupClosed: () => void;
25
+ clipboardTextReceived: (options: {
26
+ data: string;
27
+ }) => void;
28
+ writeAccessRequested: (options: {
29
+ status: "allowed" | "cancelled";
30
+ }) => void;
31
+ biometricManagerUpdated: () => void;
32
+ biometricAuthRequested: (options: {
33
+ isAuthenticated: boolean;
34
+ biometricToken: string | null;
35
+ }) => void;
36
+ biometricTokenUpdated: (options: {
37
+ isUpdated: boolean;
38
+ }) => void;
39
+ fullscreenChanged: () => void;
40
+ fullscreenFailed: (options: {
41
+ error: "UNSUPPORTED" | "ALREADY_FULLSCREEN";
42
+ }) => void;
43
+ homeScreenAdded: () => void;
44
+ homeScreenChecked: (options: {
45
+ status: "unsupported" | "unknown" | "added" | "missed";
46
+ }) => void;
47
+ accelerometerStarted: () => void;
48
+ accelerometerStopped: () => void;
49
+ accelerometerChanged: () => void;
50
+ accelerometerFailed: (options: {
51
+ error: "UNSUPPORTED";
52
+ }) => void;
53
+ deviceOrientationStarted: () => void;
54
+ deviceOrientationStopped: () => void;
55
+ deviceOrientationChanged: () => void;
56
+ deviceOrientationFailed: (options: {
57
+ error: "UNSUPPORTED";
58
+ }) => void;
59
+ gyroscopeStarted: () => void;
60
+ gyroscopeStopped: () => void;
61
+ gyroscopeChanged: () => void;
62
+ gyroscopeFailed: (options: {
63
+ error: "UNSUPPORTED";
64
+ }) => void;
65
+ locationManagerUpdated: () => void;
66
+ locationRequested: (options: {
67
+ locationData: LocationData;
68
+ }) => void;
69
+ shareMessageSent: () => void;
70
+ shareMessageFailed: (options: {
71
+ error: "UNSUPPORTED" | "MESSAGE_EXPIRED" | "MESSAGE_SEND_FAILED" | "USER_DECLINED" | "UNKNOWN_ERROR";
72
+ }) => void;
73
+ emojiStatusSet: () => void;
74
+ emojiStatusFailed: (options: {
75
+ error: "UNSUPPORTED" | "SUGGESTED_EMOJI_INVALID" | "DURATION_INVALID" | "USER_DECLINED" | "SERVER_ERROR" | "UNKNOWN_ERROR";
76
+ }) => void;
77
+ emojiStatusAccessRequested: (options: {
78
+ status: "allowed" | "cancelled";
79
+ }) => void;
80
+ fileDownloadRequested: (options: {
81
+ status: "downloading" | "cancelled";
82
+ }) => void;
83
+ };
84
+
85
+ interface WebApp {
86
+ initData: string;
87
+ initDataUnsafe: WebAppInitData;
88
+ version: string;
89
+ platform: string;
90
+ colorScheme: string;
91
+ themeParams: ThemeParams;
92
+ isActive: boolean;
93
+ isExpanded: boolean;
94
+ viewportHeight: number;
95
+ viewportStableHeight: number;
96
+ headerColor: string;
97
+ backgroundColor: string;
98
+ bottomBarColor: string;
99
+ isClosingConfirmationEnabled: boolean;
100
+ isVerticalSwipesEnabled: boolean;
101
+ isFullscreen: boolean;
102
+ isOrientationLocked: boolean;
103
+ safeAreaInset: SafeAreaInset;
104
+ contentSafeAreaInset: ContentSafeAreaInset;
105
+ BackButton: BackButton;
106
+ MainButton: BottomButton;
107
+ SecondaryButton: BottomButton;
108
+ SettingsButton: SettingsButton;
109
+ HapticFeedback: HapticFeedback;
110
+ CloudStorage: CloudStorage;
111
+ BiometricManager: BiometricManager;
112
+ Accelerometer: Accelerometer;
113
+ DeviceOrientation: DeviceOrientation;
114
+ Gyroscope: Gyroscope;
115
+ LocationManager: LocationManager;
116
+ DeviceStorage: DeviceStorage;
117
+ SecureStorage: SecureStorage;
118
+ isVersionAtLeast: (version: string) => boolean;
119
+ setHeaderColor: (color: string) => void;
120
+ setBackgroundColor: (color: string) => void;
121
+ setBottomBarColor: (color: string) => void;
122
+ enableClosingConfirmation: () => void;
123
+ disableClosingConfirmation: () => void;
124
+ enableVerticalSwipes: () => void;
125
+ disableVerticalSwipes: () => void;
126
+ requestFullscreen: () => void;
127
+ exitFullscreen: () => void;
128
+ lockOrientation: () => void;
129
+ unlockOrientation: () => void;
130
+ addToHomeScreen: () => void;
131
+ checkHomeScreenStatus: (callback?: (status: "unsupported" | "unknown" | "added" | "missed") => void) => void;
132
+ onEvent: BindOrUnbindEventHandler;
133
+ offEvent: BindOrUnbindEventHandler;
134
+ sendData: (data: string) => void;
135
+ switchInlineQuery: (query: string, chat_type?: "users" | "bots" | "groups" | "channels") => void;
136
+ openLink: (url: string, options?: {
137
+ try_instant_view: boolean;
138
+ }) => void;
139
+ openTelegramLink: (url: string) => void;
140
+ openInvoice: (url: string, callback?: (invoiceStatus: unknown) => void) => void;
141
+ shareToStory: (mediaUrl: string, options?: StoryShareParams) => void;
142
+ shareMessage: (msg_id: number, options?: (isSent: boolean) => void) => void;
143
+ setEmojiStatus: (custom_emoj_id: string, params?: EmojiStatusParams, callback?: (isStatusSet: boolean) => void) => void;
144
+ requestEmojiStatusAccess: (url: string, callback?: (invoiceStatus: unknown) => void) => void;
145
+ downloadFile: (params: DownloadFileParams, callback?: (isAccepted: boolean) => void) => void;
146
+ showPopup: (params: PopupParams, callback?: (buttonId: string) => void) => void;
147
+ showAlert: (message: string, callback?: () => void) => void;
148
+ showConfirm: (message: string, callback?: (isOk: boolean) => void) => void;
149
+ showScanQrPopup: (params: ScanQrPopupParams, callback?: (data: string) => boolean) => void;
150
+ closeScanQrPopup: () => void;
151
+ readTextFromClipboard: (callback?: (text: string) => void) => void;
152
+ requestWriteAccess: (callback?: (isGranted: boolean) => void) => void;
153
+ requestContact: (callback?: (isShared: boolean) => void) => void;
154
+ ready: () => void;
155
+ expand: () => void;
156
+ close: () => void;
157
+ }
158
+ interface Accelerometer {
159
+ isStarted: boolean;
160
+ x: number;
161
+ y: number;
162
+ z: number;
163
+ start: (params: AccelerometerStartParams, callback?: (isStarted: boolean) => void) => Accelerometer;
164
+ stop: (callback?: (isStopped: boolean) => void) => Accelerometer;
165
+ }
166
+ interface AccelerometerStartParams {
167
+ refresh_rate?: number;
168
+ }
169
+ interface BackButton {
170
+ isVisible: boolean;
171
+ onClick: EventHandlers["backButtonClicked"];
172
+ offClick: EventHandlers["backButtonClicked"];
173
+ show: () => BackButton;
174
+ hide: () => BackButton;
175
+ }
176
+ interface BiometricAuthenticateParams {
177
+ reason?: string;
178
+ }
179
+ interface BiometricManager {
180
+ isInited: boolean;
181
+ isBiometricAvailable: boolean;
182
+ biometricType: "finger" | "face" | "unknown";
183
+ isAccessRequested: boolean;
184
+ isAccessGranted: boolean;
185
+ isBiometricTokenSaved: boolean;
186
+ deviceId: string;
187
+ init: (callback?: () => void) => BiometricManager;
188
+ requestAccess: (params: BiometricRequestAccessParams, callback?: (isGranted: boolean) => void) => BiometricManager;
189
+ authenticate: (params: BiometricAuthenticateParams, callback?: (isAuthenticated: boolean) => void) => BiometricManager;
190
+ updateBiometricToken: (token: string, callback?: (isTokenUpdated: boolean) => void) => BiometricManager;
191
+ openSettings: () => BiometricManager;
192
+ }
193
+ interface BiometricRequestAccessParams {
194
+ reason?: string;
195
+ }
196
+ interface BottomButton {
197
+ type: string;
198
+ text: string;
199
+ color: string;
200
+ textColor: string;
201
+ isVisible: boolean;
202
+ isActive: boolean;
203
+ hasShineEffect: boolean;
204
+ position: string;
205
+ isProgressVisible: boolean;
206
+ setText: (text: string) => BottomButton;
207
+ onClick: (callback: () => void) => BottomButton;
208
+ offClick: (callback: () => void) => BottomButton;
209
+ show: () => BottomButton;
210
+ hide: () => BottomButton;
211
+ enable: () => BottomButton;
212
+ disable: () => BottomButton;
213
+ showProgress: (callback: (leaveActive: boolean) => void) => BottomButton;
214
+ hideProgress: () => BottomButton;
215
+ setParams: (params: {
216
+ text: string;
217
+ color: string;
218
+ has_shine_effect: boolean;
219
+ position: unknown;
220
+ is_active: boolean;
221
+ is_visible: boolean;
222
+ }) => BottomButton;
223
+ }
224
+ interface CloudStorage {
225
+ setItem: (key: string, value: string, callback?: (error: unknown | null) => void) => CloudStorage;
226
+ getItem: (key: string, callback: (error: unknown | null, value: string | null) => void) => CloudStorage;
227
+ getItems: (keys: string[], callback: (error: string | null, values: Record<string, string> | null) => void) => CloudStorage;
228
+ removeItem: (key: string, callback?: (error: string | null, isDeleted: boolean) => void) => CloudStorage;
229
+ removeItems: (keys: string[], callback?: (error: string | null, isDeleted: boolean) => void) => CloudStorage;
230
+ getKeys: (callback: (error: string | null, keys: string[] | null) => void) => CloudStorage;
231
+ }
232
+ interface ContentSafeAreaInset {
233
+ top: number;
234
+ bottom: number;
235
+ left: number;
236
+ right: number;
237
+ }
238
+ interface DeviceOrientation {
239
+ isStarted: boolean;
240
+ absolute: boolean;
241
+ alpha: number;
242
+ beta: number;
243
+ gamma: number;
244
+ start: (params: DeviceOrientationStartParams, callback?: (isTracking: boolean) => void) => void;
245
+ stop: (callback?: (isStopped: boolean) => void) => void;
246
+ }
247
+ interface DeviceOrientationStartParams {
248
+ refresh_rate?: number;
249
+ need_absolute?: boolean;
250
+ }
251
+ interface DeviceStorage {
252
+ setItem: (key: string, value: string, callback?: (error: unknown | null, isStored: boolean) => void) => DeviceStorage;
253
+ getItem: (key: string, callback: (error: unknown | null, value: string | null) => void) => DeviceStorage;
254
+ removeItem: (key: string, callback?: (error: unknown | null, isRemoved: boolean) => void) => DeviceStorage;
255
+ clear: (callback?: (error: unknown | null, isCleared: boolean) => void) => DeviceStorage;
256
+ }
257
+ interface DownloadFileParams {
258
+ url: string;
259
+ file_name: string;
260
+ }
261
+ interface EmojiStatusParams {
262
+ duration?: number;
263
+ }
264
+ interface Gyroscope {
265
+ isStarted: boolean;
266
+ x: number;
267
+ y: number;
268
+ z: number;
269
+ start: (params: GyroscopeStartParams, callback?: (isTracking: boolean) => void) => void;
270
+ stop: (callback?: (isStopped: boolean) => void) => void;
271
+ }
272
+ interface GyroscopeStartParams {
273
+ refresh_rate?: number;
274
+ }
275
+ interface HapticFeedback {
276
+ impactOccurred: (style: "light" | "medium" | "heavy" | "rigid" | "soft") => void;
277
+ notificationOccurred: (type: "error" | "success" | "warning") => void;
278
+ selectionChanged: () => HapticFeedback;
279
+ }
280
+ interface LocationData {
281
+ latitude: number;
282
+ longitude: number;
283
+ altitude: number;
284
+ course: number;
285
+ speed: number;
286
+ horizontal_accuracy: number;
287
+ vertical_accuracy: number;
288
+ course_accuracy: number;
289
+ speed_accuracy: number;
290
+ }
291
+ interface LocationManager {
292
+ isInited: boolean;
293
+ isLocationAvailable: boolean;
294
+ isAccessRequested: boolean;
295
+ isAccessGranted: boolean;
296
+ init: (callback?: () => void) => LocationManager;
297
+ getLocation: (callback: (location: LocationData | null) => void) => LocationManager;
298
+ openSettings: () => LocationManager;
299
+ }
300
+ interface PopupButton {
301
+ id?: string;
302
+ type?: "OK" | "Close" | "Cancel";
303
+ text?: string;
304
+ }
305
+ interface PopupParams {
306
+ message: string;
307
+ title?: string;
308
+ buttons?: PopupButton[];
309
+ }
310
+ interface SafeAreaInset {
311
+ top: number;
312
+ bottom: number;
313
+ left: number;
314
+ right: number;
315
+ }
316
+ interface ScanQrPopupParams {
317
+ text?: string;
318
+ }
319
+ interface SecureStorage {
320
+ setItem: (key: string, value: string, callback?: (error: unknown | null, isStored: boolean) => void) => SecureStorage;
321
+ getItem: (key: string, callback: (error: unknown | null, value: string | null, canBeRestored: boolean) => void) => SecureStorage;
322
+ restoreItem: (key: string, callback?: (error: unknown | null, value: string | null) => void) => SecureStorage;
323
+ removeItem: (key: string, callback?: (error: unknown | null, isRemoved: boolean) => void) => SecureStorage;
324
+ clear: (callback?: (error: unknown | null, isCleared: boolean) => void) => SecureStorage;
325
+ }
326
+ interface SettingsButton {
327
+ isVisible: boolean;
328
+ onClick: (callback: () => void) => SettingsButton;
329
+ offClick: (callback: () => void) => SettingsButton;
330
+ show: () => SettingsButton;
331
+ hide: () => SettingsButton;
332
+ }
333
+ interface StoryShareParams {
334
+ text?: string;
335
+ widget_link?: StoryWidgetLink;
336
+ }
337
+ interface StoryWidgetLink {
338
+ url: string;
339
+ name?: string;
340
+ }
341
+ interface ThemeParams {
342
+ bg_color?: string;
343
+ text_color?: string;
344
+ hint_color?: string;
345
+ link_color?: string;
346
+ button_color?: string;
347
+ button_text_color?: string;
348
+ secondary_bg_color?: string;
349
+ header_bg_color?: string;
350
+ bottom_bar_bg_color?: string;
351
+ accent_text_color?: string;
352
+ section_bg_color?: string;
353
+ section_header_text_color?: string;
354
+ section_separator_color?: string;
355
+ subtitle_text_color?: string;
356
+ destructive_text_color?: string;
357
+ }
358
+ interface WebAppChat {
359
+ id: number;
360
+ type: "group" | "supergroup" | "channel";
361
+ title: string;
362
+ username?: string;
363
+ photo_url?: "in";
364
+ }
365
+ interface WebAppInitData {
366
+ auth_date: number;
367
+ hash: string;
368
+ signature: string;
369
+ query_id?: string;
370
+ user?: WebAppUser;
371
+ receiver?: WebAppUser;
372
+ chat?: WebAppChat;
373
+ chat_type?: string;
374
+ chat_instance?: string;
375
+ start_param?: string;
376
+ can_send_after?: number;
377
+ }
378
+ interface WebAppUser {
379
+ id: number;
380
+ first_name: string;
381
+ is_bot?: boolean;
382
+ last_name?: string;
383
+ username?: string;
384
+ language_code?: string;
385
+ is_premium?: boolean;
386
+ added_to_attachment_menu?: boolean;
387
+ allows_write_to_pm?: boolean;
388
+ photo_url?: "in";
389
+ }
390
+
391
+ export type { Accelerometer, AccelerometerStartParams, BackButton, BiometricAuthenticateParams, BiometricManager, BiometricRequestAccessParams, BottomButton, CloudStorage, ContentSafeAreaInset, DeviceOrientation, DeviceOrientationStartParams, DeviceStorage, DownloadFileParams, EmojiStatusParams, Gyroscope, GyroscopeStartParams, HapticFeedback, LocationData, LocationManager, PopupButton, PopupParams, SafeAreaInset, ScanQrPopupParams, SecureStorage, SettingsButton, StoryShareParams, StoryWidgetLink, ThemeParams, WebApp, WebAppChat, WebAppInitData, WebAppUser };
package/dist/webapp.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";var m=Object.defineProperty;var t=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var b=(r,o,p,f)=>{if(o&&typeof o=="object"||typeof o=="function")for(let e of x(o))!a.call(r,e)&&e!==p&&m(r,e,{get:()=>o[e],enumerable:!(f=t(o,e))||f.enumerable});return r};var c=r=>b(m({},"__esModule",{value:!0}),r);var d={};module.exports=c(d);
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effect-ak/tg-bot-client",
3
- "version": "0.5.3",
3
+ "version": "0.6.0",
4
4
  "homepage": "https://effect-ak.github.io/telegram-bot-playground/",
5
5
  "author": {
6
6
  "name": "Aleksandr Kondaurov",
@@ -9,19 +9,24 @@
9
9
  "publishConfig": {
10
10
  "access": "public"
11
11
  },
12
- "description": "Telegram bot client",
12
+ "description": "TypeScript types for Telegram Bot Api and Telegram.Webapp",
13
13
  "files": [
14
- "dist/index.js",
15
- "dist/index.mjs",
16
- "dist/index.d.ts"
14
+ "dist/*.js",
15
+ "dist/*.mjs",
16
+ "dist/*.d.ts"
17
17
  ],
18
18
  "keywords": [
19
- "telegram",
20
- "telegram bot api"
19
+ "telegram typescript types",
20
+ "telegram bot api client",
21
+ "telegram webapp"
21
22
  ],
22
23
  "repository": {
24
+ "type": "git",
23
25
  "url": "https://github.com/effect-ak/tg-bot-client"
24
26
  },
27
+ "bugs": {
28
+ "url": "https://github.com/effect-ak/tg-bot-client/issues"
29
+ },
25
30
  "license": "MIT",
26
31
  "types": "./dist/index.d.ts",
27
32
  "main": "./dist/index.js",
@@ -31,6 +36,16 @@
31
36
  "types": "./dist/index.d.ts",
32
37
  "require": "./dist/index.js",
33
38
  "import": "./dist/index.mjs"
39
+ },
40
+ "./bot": {
41
+ "types": "./dist/bot.d.ts",
42
+ "require": "./dist/bot.js",
43
+ "import": "./dist/bot.mjs"
44
+ },
45
+ "./webapp": {
46
+ "types": "./dist/webapp.d.ts",
47
+ "require": "./dist/webapp.js",
48
+ "import": "./dist/webapp.mjs"
34
49
  }
35
50
  },
36
51
  "devDependencies": {
@@ -44,6 +59,9 @@
44
59
  "typescript": "^5.8.3",
45
60
  "vite-tsconfig-paths": "^5.1.4",
46
61
  "vitest": "^3.1.1",
47
- "effect": "^3.14.7"
62
+ "effect": "3.12.0"
63
+ },
64
+ "peerDependencies": {
65
+ "effect": "^3.12.0"
48
66
  }
49
67
  }
package/readme.md CHANGED
@@ -1,20 +1,19 @@
1
1
  [![NPM Version](https://img.shields.io/npm/v/%40effect-ak%2Ftg-bot-client)](https://www.npmjs.com/package/@effect-ak/tg-bot-client)
2
+ ![Telegram Bot API](https://img.shields.io/badge/BotApi-9.0-blue?link=)
3
+ ![Telegram WebApp](https://img.shields.io/badge/Telegram.WebApp-9.0-blue?link=)
2
4
  [![OpenAPI](https://img.shields.io/badge/OpenAPI-3.1-blue.svg)](https://effect-ak.github.io/telegram-bot-api/)
3
- ![NPM Unpacked Size](https://img.shields.io/npm/unpacked-size/%40effect-ak%2Ftg-bot-client)
4
- ![NPM Downloads](https://img.shields.io/npm/dw/%40effect-ak%2Ftg-bot-client)
5
-
6
-
5
+ ![NPM Unpacked Size](https://img.shields.io/npm/unpacked-size/%40effect-ak%2Ftg-bot-client?link=)
6
+ ![NPM Downloads](https://img.shields.io/npm/dw/%40effect-ak%2Ftg-bot-client?link=)
7
7
 
8
8
  ## Motivation
9
+ **Telegram** does not offer an official TypeScript **SDK** for their **API** but they provide documentation in HTML format.
9
10
 
10
- The official documentation is available as a comprehensive [HTML page](https://core.telegram.org/bots/api), providing basic navigation. While functional, relying solely on this format can be somewhat inconvenient during bot **development**.
11
-
12
- This client facilitates interaction with the **Telegram Bot API**. It was created primarily because **Telegram** does not offer an official TypeScript **SDK** for their **API**.
11
+ This package aims to parse official documentation of [Bot Api](https://core.telegram.org/bots/api) and [Telegram.Webapp](https://core.telegram.org/bots/api) and generate **TypeScript types**!
13
12
 
14
13
  ## Highlights:
15
14
  - **[Client](#client)**: Light TypeScript client
16
15
  - **Complete and Up-to-Date Telegram Bot API**: The entire API is generated from [the official documentation](https://core.telegram.org/bots/api) using a [code generator](./codegen/main.ts), ensuring this client remains in sync and supports every method and type provided by the **Telegram Bot API**.
17
- - **[Types for Webapps](#webapps-typings)** Types that describe `Telegram.WebApp`
16
+ - **[Types for Webapps](#webapps-typings)** Types that describe `Telegram.WebApp`. Created by [code generator](./codegen/main.ts) as well.
18
17
  - **[ChatBot runner](#chatbot-runner)**: Focus on the logic of your chat bot
19
18
  - **Type Mapping**: Types from the documentation are converted to TypeScript types:
20
19
  - `Integer` → `number`
@@ -33,7 +32,7 @@ const client = makeTgBotClient({
33
32
  });
34
33
  ```
35
34
 
36
- ### Executing api methods
35
+ ### Executing api methods (Promise based)
37
36
 
38
37
  `client` has an `execute` method which requires two arguments
39
38
 
@@ -57,6 +56,8 @@ await client.execute("send_message", {
57
56
  #### 2. Sending a Dice
58
57
 
59
58
  ```typescript
59
+ import { MESSAGE_EFFECTS } from "@effect-ak/tg-bot-client"
60
+
60
61
  await client.execute("send_dice", {
61
62
  chat_id: "???", // replace ??? with the chat number
62
63
  emoji: "🎲"
@@ -66,6 +67,8 @@ await client.execute("send_dice", {
66
67
  #### 3. Sending a Document
67
68
 
68
69
  ```typescript
70
+ import { MESSAGE_EFFECTS } from "@effect-ak/tg-bot-client"
71
+
69
72
  await client.execute("send_document", {
70
73
  chat_id: "???", // replace ??? with the chat number
71
74
  message_effect_id: MESSAGE_EFFECTS["🎉"],
@@ -93,6 +96,22 @@ const file =
93
96
  });
94
97
  ```
95
98
 
99
+ ### Executing api methods (Effect based)
100
+
101
+ If you want to use [Effect](https://effect.website/) instead of `Promise`:
102
+ ```typescript
103
+ import { executeTgBotMethod, TgBotApiToken } from "@effect-ak/tg-bot-client";
104
+ import { Effect } from "effect";
105
+
106
+ executeTgBotMethod("send_message", {
107
+ text: "hello",
108
+ chat_id: config.chat_id
109
+ }).pipe(
110
+ Effect.provideService(TgBotApiToken, 'your-token-from-bot-father'),
111
+ Effect.runPromiseExit
112
+ )
113
+ ```
114
+
96
115
  ## ChatBot runner
97
116
 
98
117
  ### How this library helps
@@ -113,24 +132,13 @@ Take a look at examples [here](example)
113
132
 
114
133
  ### Setup Instructions
115
134
 
116
- 1. **Create a `config.json` File**
117
-
118
- In the root of your project, create a `config.json` file with the following content:
119
-
120
- ```json
121
- {
122
- "bot-token": "your-token"
123
- }
124
- ```
125
-
126
- Replace `"your-token"` with your actual Telegram bot token.
127
-
128
- 2. **Create `bot.js` and Implement Your Bot's Logic**
135
+ 1. **Create `bot.js` and Implement Your Bot's Logic**
129
136
 
130
- Create a file named `bot.js` and add your bot's logic as shown below:
137
+ Create a file (for example `bot.js`) and add your bot's logic as shown below:
131
138
 
132
139
  ```typescript
133
- import { MESSAGE_EFFECTS, runTgChatBot, BotResponse, defineBot } from "@effect-ak/tg-bot-client"
140
+ import { MESSAGE_EFFECTS } from "@effect-ak/tg-bot-client"
141
+ import { runTgChatBot, BotResponse, defineBot } from "@effect-ak/tg-bot-client/bot"
134
142
 
135
143
  const BOT = defineBot({
136
144
  on_message: (msg) => {
@@ -153,7 +161,7 @@ Take a look at examples [here](example)
153
161
  })
154
162
 
155
163
  runTgChatBot({
156
- type: "fromJsonFile",
164
+ bot_token: "your-token" // PUT YOUR TOKEN HERE
157
165
  mode: {
158
166
  type: "single",
159
167
  ...BOT
@@ -161,7 +169,7 @@ Take a look at examples [here](example)
161
169
  })
162
170
  ```
163
171
 
164
- 3. **Run the Bot**
172
+ 2. **Run the Bot**
165
173
 
166
174
  To start your chatbot, execute the following command in your terminal:
167
175
 
@@ -205,10 +213,10 @@ graph TD
205
213
 
206
214
  Telegram provides a big [html](https://core.telegram.org/bots/webapps) page that describes `Telegram.WebApp`
207
215
 
208
- `@effect-ak/tg-bot-client` levereges scrapper's functionality to generate TypeScript types.
216
+ `@effect-ak/tg-bot-client` leverages scrapper's functionality to generate TypeScript types.
209
217
 
210
218
  ```typescript
211
- import { TgWebApp } from "@effect-ak/tg-bot-client";
219
+ import type { WebApp } from "@effect-ak/tg-bot-client/webapp";
212
220
 
213
221
  interface Telegram {
214
222
  WebApp: TgWebApp