@riseonly/sdk 0.1.1-next.0 → 0.1.2
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 +46 -9
- package/dist/index.cjs +314 -79
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +56 -34
- package/dist/index.d.ts +56 -34
- package/dist/index.js +314 -81
- package/dist/index.js.map +1 -1
- package/package.json +6 -1
package/dist/index.d.ts
CHANGED
|
@@ -45,6 +45,7 @@ interface ClientOptions {
|
|
|
45
45
|
interface RequestOptions {
|
|
46
46
|
requestId?: string;
|
|
47
47
|
signal?: AbortSignal;
|
|
48
|
+
timeoutMs?: number;
|
|
48
49
|
}
|
|
49
50
|
interface User {
|
|
50
51
|
id: string;
|
|
@@ -58,7 +59,7 @@ interface User {
|
|
|
58
59
|
is_premium?: boolean;
|
|
59
60
|
is_official?: boolean;
|
|
60
61
|
is_online?: boolean;
|
|
61
|
-
last_seen?:
|
|
62
|
+
last_seen?: number;
|
|
62
63
|
bot_owner_id?: string;
|
|
63
64
|
can_join_groups?: boolean;
|
|
64
65
|
supports_inline_queries?: boolean;
|
|
@@ -66,12 +67,15 @@ interface User {
|
|
|
66
67
|
}
|
|
67
68
|
interface Chat {
|
|
68
69
|
id: string;
|
|
69
|
-
type
|
|
70
|
+
type?: 'private' | 'group' | 'channel' | string;
|
|
70
71
|
title?: string;
|
|
71
72
|
username?: string;
|
|
72
73
|
description?: string;
|
|
74
|
+
photo?: string;
|
|
73
75
|
avatar_url?: string;
|
|
74
76
|
member_count?: number;
|
|
77
|
+
is_public?: boolean;
|
|
78
|
+
is_verified?: boolean;
|
|
75
79
|
}
|
|
76
80
|
interface MediaVariant {
|
|
77
81
|
variant_type?: string;
|
|
@@ -233,94 +237,86 @@ interface SetWebhookResult {
|
|
|
233
237
|
url: string;
|
|
234
238
|
enabled: boolean;
|
|
235
239
|
}
|
|
236
|
-
interface SendMessageOptions {
|
|
240
|
+
interface SendMessageOptions extends RequestOptions {
|
|
237
241
|
chat_id: string;
|
|
238
|
-
text
|
|
239
|
-
caption?: string;
|
|
242
|
+
text: string;
|
|
240
243
|
parse_mode?: string;
|
|
241
244
|
disable_notification?: boolean;
|
|
242
245
|
reply_to_message_id?: string;
|
|
243
246
|
reply_markup?: ReplyMarkup;
|
|
244
|
-
requestId?: string;
|
|
245
247
|
}
|
|
246
|
-
interface SendMediaOptions {
|
|
248
|
+
interface SendMediaOptions extends RequestOptions {
|
|
247
249
|
chat_id: string;
|
|
248
250
|
caption?: string;
|
|
249
251
|
disable_notification?: boolean;
|
|
250
252
|
reply_to_message_id?: string;
|
|
251
253
|
reply_markup?: ReplyMarkup;
|
|
252
|
-
requestId?: string;
|
|
253
254
|
}
|
|
254
|
-
interface EditMessageTextOptions {
|
|
255
|
+
interface EditMessageTextOptions extends RequestOptions {
|
|
255
256
|
chat_id?: string;
|
|
256
257
|
message_id?: string;
|
|
257
258
|
inline_message_id?: string;
|
|
258
259
|
text: string;
|
|
259
260
|
parse_mode?: string;
|
|
260
261
|
reply_markup?: ReplyMarkup;
|
|
261
|
-
requestId?: string;
|
|
262
262
|
}
|
|
263
|
-
interface DeleteMessageOptions {
|
|
263
|
+
interface DeleteMessageOptions extends RequestOptions {
|
|
264
264
|
chat_id: string;
|
|
265
265
|
message_id: string;
|
|
266
|
-
requestId?: string;
|
|
267
266
|
}
|
|
268
|
-
interface SendChatActionOptions {
|
|
267
|
+
interface SendChatActionOptions extends RequestOptions {
|
|
269
268
|
chat_id: string;
|
|
270
269
|
action: ChatAction;
|
|
271
|
-
requestId?: string;
|
|
272
270
|
}
|
|
273
|
-
interface GetUpdatesOptions {
|
|
271
|
+
interface GetUpdatesOptions extends RequestOptions {
|
|
274
272
|
offset?: number;
|
|
275
273
|
limit?: number;
|
|
276
274
|
timeout?: number;
|
|
277
275
|
allowed_updates?: UpdateType[];
|
|
278
|
-
requestId?: string;
|
|
279
|
-
signal?: AbortSignal;
|
|
280
276
|
}
|
|
281
|
-
interface SetWebhookOptions {
|
|
277
|
+
interface SetWebhookOptions extends RequestOptions {
|
|
282
278
|
url: string;
|
|
283
279
|
secret_token?: string;
|
|
284
280
|
max_connections?: number;
|
|
285
281
|
allowed_updates?: UpdateType[];
|
|
286
282
|
drop_pending_updates?: boolean;
|
|
287
|
-
requestId?: string;
|
|
288
283
|
}
|
|
289
|
-
interface DeleteWebhookOptions {
|
|
284
|
+
interface DeleteWebhookOptions extends RequestOptions {
|
|
290
285
|
drop_pending_updates?: boolean;
|
|
291
|
-
requestId?: string;
|
|
292
286
|
}
|
|
293
|
-
interface SetMyCommandsOptions {
|
|
287
|
+
interface SetMyCommandsOptions extends RequestOptions {
|
|
294
288
|
commands: BotCommand[];
|
|
295
289
|
scope?: CommandScope;
|
|
296
290
|
language_code?: string;
|
|
297
|
-
requestId?: string;
|
|
298
291
|
}
|
|
299
|
-
interface GetMyCommandsOptions {
|
|
292
|
+
interface GetMyCommandsOptions extends RequestOptions {
|
|
300
293
|
scope?: CommandScope;
|
|
301
294
|
language_code?: string;
|
|
302
|
-
requestId?: string;
|
|
303
295
|
}
|
|
304
|
-
interface DeleteMyCommandsOptions {
|
|
296
|
+
interface DeleteMyCommandsOptions extends RequestOptions {
|
|
305
297
|
scope?: CommandScope;
|
|
306
298
|
language_code?: string;
|
|
307
|
-
requestId?: string;
|
|
308
299
|
}
|
|
309
|
-
interface AnswerCallbackQueryOptions {
|
|
300
|
+
interface AnswerCallbackQueryOptions extends RequestOptions {
|
|
310
301
|
callback_query_id: string;
|
|
311
302
|
text?: string;
|
|
312
303
|
show_alert?: boolean;
|
|
313
304
|
url?: string;
|
|
314
|
-
requestId?: string;
|
|
315
305
|
}
|
|
316
|
-
interface GetChatOptions {
|
|
306
|
+
interface GetChatOptions extends RequestOptions {
|
|
317
307
|
chat_id: string;
|
|
318
|
-
requestId?: string;
|
|
319
308
|
}
|
|
320
|
-
|
|
309
|
+
interface MediaReference {
|
|
321
310
|
file_id?: string;
|
|
322
311
|
url?: string;
|
|
323
|
-
|
|
312
|
+
file_name?: string;
|
|
313
|
+
mime_type?: string;
|
|
314
|
+
thumbnail_url?: string;
|
|
315
|
+
duration?: number;
|
|
316
|
+
width?: number;
|
|
317
|
+
height?: number;
|
|
318
|
+
}
|
|
319
|
+
type MediaInput = string | MediaReference;
|
|
324
320
|
interface PollingOptions {
|
|
325
321
|
interval?: number;
|
|
326
322
|
timeout?: number;
|
|
@@ -333,15 +329,23 @@ interface WebhookServerOptions {
|
|
|
333
329
|
host?: string;
|
|
334
330
|
port?: number;
|
|
335
331
|
secretToken?: string;
|
|
332
|
+
maxBodyBytes?: number;
|
|
336
333
|
}
|
|
337
334
|
interface BotOptions extends ClientOptions {
|
|
338
335
|
polling?: boolean | PollingOptions;
|
|
339
336
|
webhook?: false | WebhookServerOptions;
|
|
340
337
|
allowed_updates?: UpdateType[];
|
|
341
338
|
}
|
|
339
|
+
interface BotSetupOptions {
|
|
340
|
+
commands?: BotCommand[];
|
|
341
|
+
commandScope?: CommandScope;
|
|
342
|
+
languageCode?: string;
|
|
343
|
+
webhook?: SetWebhookOptions | false;
|
|
344
|
+
}
|
|
342
345
|
type MessageHandler = (message: Message, update: Update) => void | Promise<void>;
|
|
343
346
|
type EditedMessageHandler = (message: Message, update: Update) => void | Promise<void>;
|
|
344
347
|
type CallbackQueryHandler = (query: CallbackQuery, update: Update) => void | Promise<void>;
|
|
348
|
+
type TextHandler = (message: Message, match: RegExpExecArray | null, update: Update) => void | Promise<void>;
|
|
345
349
|
type UpdateHandler = (update: Update) => void | Promise<void>;
|
|
346
350
|
type ErrorHandler = (error: unknown) => void | Promise<void>;
|
|
347
351
|
type PollingErrorHandler = (error: unknown) => void | Promise<void>;
|
|
@@ -400,6 +404,7 @@ declare class ApiClient {
|
|
|
400
404
|
private sendMedia;
|
|
401
405
|
private normalizeMedia;
|
|
402
406
|
private buildMethodUrl;
|
|
407
|
+
private fetchJson;
|
|
403
408
|
}
|
|
404
409
|
|
|
405
410
|
declare class RiseonlyBot extends ApiClient {
|
|
@@ -408,6 +413,7 @@ declare class RiseonlyBot extends ApiClient {
|
|
|
408
413
|
private webhookOptions?;
|
|
409
414
|
private polling;
|
|
410
415
|
private pollingAbort?;
|
|
416
|
+
private pollingTask?;
|
|
411
417
|
private offset;
|
|
412
418
|
private webhookServer?;
|
|
413
419
|
constructor(token: string, options?: BotOptions);
|
|
@@ -423,6 +429,11 @@ declare class RiseonlyBot extends ApiClient {
|
|
|
423
429
|
* Registers a one-time event listener.
|
|
424
430
|
*/
|
|
425
431
|
once<T extends BotEvent>(event: T, handler: BotEventMap[T]): this;
|
|
432
|
+
command(commands: string | string[], handler: BotEventMap['message']): this;
|
|
433
|
+
hears(trigger: string | RegExp, handler: TextHandler): this;
|
|
434
|
+
action(trigger: string | RegExp, handler: BotEventMap['callback_query']): this;
|
|
435
|
+
catch(handler: BotEventMap['error']): this;
|
|
436
|
+
setup(options: BotSetupOptions): Promise<void>;
|
|
426
437
|
/**
|
|
427
438
|
* Starts long polling for bot updates.
|
|
428
439
|
*/
|
|
@@ -431,6 +442,8 @@ declare class RiseonlyBot extends ApiClient {
|
|
|
431
442
|
* Stops long polling.
|
|
432
443
|
*/
|
|
433
444
|
stopPolling(): Promise<void>;
|
|
445
|
+
launch(options?: PollingOptions): Promise<void>;
|
|
446
|
+
stop(): Promise<void>;
|
|
434
447
|
/**
|
|
435
448
|
* Starts a built-in HTTP server that receives webhook updates.
|
|
436
449
|
*/
|
|
@@ -453,6 +466,7 @@ declare class RiseonlyBot extends ApiClient {
|
|
|
453
466
|
answer(query: CallbackQuery, text?: string, showAlert?: boolean): Promise<boolean>;
|
|
454
467
|
private pollLoop;
|
|
455
468
|
private emit;
|
|
469
|
+
private emitError;
|
|
456
470
|
}
|
|
457
471
|
|
|
458
472
|
declare class RiseonlyError extends Error {
|
|
@@ -475,6 +489,14 @@ declare class RiseonlyNetworkError extends RiseonlyError {
|
|
|
475
489
|
declare class RiseonlyTimeoutError extends RiseonlyNetworkError {
|
|
476
490
|
constructor(message?: string);
|
|
477
491
|
}
|
|
492
|
+
declare class RiseonlyAbortError extends RiseonlyNetworkError {
|
|
493
|
+
constructor(message?: string, cause?: unknown);
|
|
494
|
+
}
|
|
495
|
+
declare class RiseonlyResponseError extends RiseonlyNetworkError {
|
|
496
|
+
readonly status: number;
|
|
497
|
+
readonly body?: string;
|
|
498
|
+
constructor(message: string, status: number, body?: string);
|
|
499
|
+
}
|
|
478
500
|
|
|
479
501
|
interface WebhookRequest {
|
|
480
502
|
headers: Record<string, string | string[] | undefined>;
|
|
@@ -532,4 +554,4 @@ declare function extractInitDataFromLaunchUrl(launchUrl: string): string | null;
|
|
|
532
554
|
*/
|
|
533
555
|
declare function createRequestId(): string;
|
|
534
556
|
|
|
535
|
-
export { type AnswerCallbackQueryOptions, ApiClient, type ApiEnvelope, type ApiErrorResponse, type ApiResponse, type BotCommand, type BotEvent, type BotEventMap, type BotOptions, CANONICAL_API_PREFIX, CHAT_ACTIONS, COMMAND_SCOPES, type CallbackQuery, type CallbackQueryHandler, type Capabilities, type Chat, type ClientOptions, DEFAULT_API_BASE, type DeleteMessageOptions, type DeleteMyCommandsOptions, type DeleteWebhookOptions, type EditMessageTextOptions, type EditedMessageHandler, type ErrorHandler, type ForceReply, type ForwardOrigin, type GetChatOptions, type GetMyCommandsOptions, type GetUpdatesOptions, IDEMPOTENCY_HEADER, type InlineKeyboardButton, type InlineKeyboardMarkup, type MediaFile, type MediaInput, type MediaVariant, type Message, type MessageEntity, type MessageHandler, type PollingErrorHandler, type PollingOptions, type ReactionCount, type ReplyKeyboardButton, type ReplyKeyboardMarkup, type ReplyKeyboardRemove, type ReplyMarkup, type RequestOptions, RiseonlyBot, RiseonlyError, RiseonlyNetworkError, RiseonlyTimeoutError, SUPPORTED_METHODS, type SendChatActionOptions, type SendMediaOptions, type SendMessageOptions, type SetMyCommandsOptions, type SetWebhookOptions, type SetWebhookResult, UPDATE_TYPES, type Update, type UpdateHandler, type User, WEBHOOK_SECRET_HEADER, type WebAppData, type WebAppInfo, type WebhookInfo, type WebhookServerOptions, buildInitDataCheckString, createRequestId, createWebhookHandler, deriveInitDataSecret, extractInitDataFromLaunchUrl, parseInitData, parseWebhookUpdate, signInitData, verifyInitData, verifyWebhookSecret };
|
|
557
|
+
export { type AnswerCallbackQueryOptions, ApiClient, type ApiEnvelope, type ApiErrorResponse, type ApiResponse, type BotCommand, type BotEvent, type BotEventMap, type BotOptions, type BotSetupOptions, CANONICAL_API_PREFIX, CHAT_ACTIONS, COMMAND_SCOPES, type CallbackQuery, type CallbackQueryHandler, type Capabilities, type Chat, type ClientOptions, DEFAULT_API_BASE, type DeleteMessageOptions, type DeleteMyCommandsOptions, type DeleteWebhookOptions, type EditMessageTextOptions, type EditedMessageHandler, type ErrorHandler, type ForceReply, type ForwardOrigin, type GetChatOptions, type GetMyCommandsOptions, type GetUpdatesOptions, IDEMPOTENCY_HEADER, type InlineKeyboardButton, type InlineKeyboardMarkup, type MediaFile, type MediaInput, type MediaReference, type MediaVariant, type Message, type MessageEntity, type MessageHandler, type PollingErrorHandler, type PollingOptions, type ReactionCount, type ReplyKeyboardButton, type ReplyKeyboardMarkup, type ReplyKeyboardRemove, type ReplyMarkup, type RequestOptions, RiseonlyAbortError, RiseonlyBot, RiseonlyError, RiseonlyNetworkError, RiseonlyResponseError, RiseonlyTimeoutError, SUPPORTED_METHODS, type SendChatActionOptions, type SendMediaOptions, type SendMessageOptions, type SetMyCommandsOptions, type SetWebhookOptions, type SetWebhookResult, type TextHandler, UPDATE_TYPES, type Update, type UpdateHandler, type User, WEBHOOK_SECRET_HEADER, type WebAppData, type WebAppInfo, type WebhookInfo, type WebhookServerOptions, buildInitDataCheckString, createRequestId, createWebhookHandler, deriveInitDataSecret, extractInitDataFromLaunchUrl, parseInitData, parseWebhookUpdate, signInitData, verifyInitData, verifyWebhookSecret };
|