@effect-ak/tg-bot-client 0.5.4 → 0.6.1
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/bot.d.ts +111 -0
- package/dist/bot.js +1 -0
- package/dist/bot.mjs +1 -0
- package/dist/config-BZUAEyeb.d.ts +3070 -0
- package/dist/index.d.ts +37 -3555
- package/dist/index.js +1 -22
- package/dist/index.mjs +1 -22
- package/dist/webapp.d.ts +391 -0
- package/dist/webapp.js +1 -0
- package/dist/webapp.mjs +0 -0
- package/package.json +18 -5
- package/readme.md +28 -19
package/dist/webapp.d.ts
ADDED
|
@@ -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);
|
package/dist/webapp.mjs
ADDED
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effect-ak/tg-bot-client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"homepage": "https://effect-ak.github.io/telegram-bot-playground/",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Aleksandr Kondaurov",
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
},
|
|
12
12
|
"description": "TypeScript types for Telegram Bot Api and Telegram.Webapp",
|
|
13
13
|
"files": [
|
|
14
|
-
"dist
|
|
15
|
-
"dist
|
|
16
|
-
"dist
|
|
14
|
+
"dist/*.js",
|
|
15
|
+
"dist/*.mjs",
|
|
16
|
+
"dist/*.d.ts"
|
|
17
17
|
],
|
|
18
18
|
"keywords": [
|
|
19
19
|
"telegram typescript types",
|
|
@@ -36,6 +36,16 @@
|
|
|
36
36
|
"types": "./dist/index.d.ts",
|
|
37
37
|
"require": "./dist/index.js",
|
|
38
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"
|
|
39
49
|
}
|
|
40
50
|
},
|
|
41
51
|
"devDependencies": {
|
|
@@ -49,6 +59,9 @@
|
|
|
49
59
|
"typescript": "^5.8.3",
|
|
50
60
|
"vite-tsconfig-paths": "^5.1.4",
|
|
51
61
|
"vitest": "^3.1.1",
|
|
52
|
-
"effect": "
|
|
62
|
+
"effect": "3.12.0"
|
|
63
|
+
},
|
|
64
|
+
"peerDependencies": {
|
|
65
|
+
"effect": "^3.12.0"
|
|
53
66
|
}
|
|
54
67
|
}
|
package/readme.md
CHANGED
|
@@ -32,7 +32,7 @@ const client = makeTgBotClient({
|
|
|
32
32
|
});
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
-
### Executing api methods
|
|
35
|
+
### Executing api methods (Promise based)
|
|
36
36
|
|
|
37
37
|
`client` has an `execute` method which requires two arguments
|
|
38
38
|
|
|
@@ -56,6 +56,8 @@ await client.execute("send_message", {
|
|
|
56
56
|
#### 2. Sending a Dice
|
|
57
57
|
|
|
58
58
|
```typescript
|
|
59
|
+
import { MESSAGE_EFFECTS } from "@effect-ak/tg-bot-client"
|
|
60
|
+
|
|
59
61
|
await client.execute("send_dice", {
|
|
60
62
|
chat_id: "???", // replace ??? with the chat number
|
|
61
63
|
emoji: "🎲"
|
|
@@ -65,6 +67,8 @@ await client.execute("send_dice", {
|
|
|
65
67
|
#### 3. Sending a Document
|
|
66
68
|
|
|
67
69
|
```typescript
|
|
70
|
+
import { MESSAGE_EFFECTS } from "@effect-ak/tg-bot-client"
|
|
71
|
+
|
|
68
72
|
await client.execute("send_document", {
|
|
69
73
|
chat_id: "???", // replace ??? with the chat number
|
|
70
74
|
message_effect_id: MESSAGE_EFFECTS["🎉"],
|
|
@@ -92,6 +96,22 @@ const file =
|
|
|
92
96
|
});
|
|
93
97
|
```
|
|
94
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
|
+
|
|
95
115
|
## ChatBot runner
|
|
96
116
|
|
|
97
117
|
### How this library helps
|
|
@@ -112,24 +132,13 @@ Take a look at examples [here](example)
|
|
|
112
132
|
|
|
113
133
|
### Setup Instructions
|
|
114
134
|
|
|
115
|
-
1. **Create
|
|
116
|
-
|
|
117
|
-
In the root of your project, create a `config.json` file with the following content:
|
|
118
|
-
|
|
119
|
-
```json
|
|
120
|
-
{
|
|
121
|
-
"bot-token": "your-token"
|
|
122
|
-
}
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
Replace `"your-token"` with your actual Telegram bot token.
|
|
126
|
-
|
|
127
|
-
2. **Create `bot.js` and Implement Your Bot's Logic**
|
|
135
|
+
1. **Create `bot.js` and Implement Your Bot's Logic**
|
|
128
136
|
|
|
129
|
-
Create a file
|
|
137
|
+
Create a file (for example `bot.js`) and add your bot's logic as shown below:
|
|
130
138
|
|
|
131
139
|
```typescript
|
|
132
|
-
import { MESSAGE_EFFECTS
|
|
140
|
+
import { MESSAGE_EFFECTS } from "@effect-ak/tg-bot-client"
|
|
141
|
+
import { runTgChatBot, BotResponse, defineBot } from "@effect-ak/tg-bot-client/bot"
|
|
133
142
|
|
|
134
143
|
const BOT = defineBot({
|
|
135
144
|
on_message: (msg) => {
|
|
@@ -152,7 +161,7 @@ Take a look at examples [here](example)
|
|
|
152
161
|
})
|
|
153
162
|
|
|
154
163
|
runTgChatBot({
|
|
155
|
-
|
|
164
|
+
bot_token: "your-token" // PUT YOUR TOKEN HERE
|
|
156
165
|
mode: {
|
|
157
166
|
type: "single",
|
|
158
167
|
...BOT
|
|
@@ -160,7 +169,7 @@ Take a look at examples [here](example)
|
|
|
160
169
|
})
|
|
161
170
|
```
|
|
162
171
|
|
|
163
|
-
|
|
172
|
+
2. **Run the Bot**
|
|
164
173
|
|
|
165
174
|
To start your chatbot, execute the following command in your terminal:
|
|
166
175
|
|
|
@@ -207,7 +216,7 @@ Telegram provides a big [html](https://core.telegram.org/bots/webapps) page that
|
|
|
207
216
|
`@effect-ak/tg-bot-client` leverages scrapper's functionality to generate TypeScript types.
|
|
208
217
|
|
|
209
218
|
```typescript
|
|
210
|
-
import {
|
|
219
|
+
import type { WebApp } from "@effect-ak/tg-bot-client/webapp";
|
|
211
220
|
|
|
212
221
|
interface Telegram {
|
|
213
222
|
WebApp: TgWebApp
|