karboai 1.6.0 → 1.7.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.RU.md CHANGED
@@ -32,6 +32,14 @@
32
32
  - [on()](#on)
33
33
  - [command()](#command)
34
34
  - [Схемы](#схемы)
35
+ - [Утилиты](#утилиты)
36
+ - [bold()](#bold)
37
+ - [italic()](#italic)
38
+ - [centralize()](#centralize)
39
+ - [code()](#code)
40
+ - [strikethrough()](#strikethrough)
41
+ - [underline()](#underline)
42
+ - [hyperlink()](#hyperlink)
35
43
  - [Логирование](#логирование)
36
44
 
37
45
  ## Установка
@@ -393,6 +401,120 @@ router.command('/start', async ({ karbo, message }) => {
393
401
  import { KarboConfig, Message, KarboContext, User } from 'karboai';
394
402
  ```
395
403
 
404
+ ## Утилиты
405
+
406
+ Вспомогательные функции для форматирования текста в сообщениях. Все утилиты экспортируются из основного пакета.
407
+
408
+ ```typescript
409
+ import { bold, italic, centralize, code, strikethrough, underline, hyperlink } from 'karboai';
410
+ ```
411
+
412
+ ### `bold(text)`
413
+
414
+ Оборачивает текст в жирное форматирование.
415
+
416
+ **Параметры:**
417
+ - `text` — Текст для форматирования
418
+
419
+ **Возвращает:** `string` — Отформатированный текст с маркерами `**`
420
+
421
+ **Пример:**
422
+ ```typescript
423
+ await karbo.text('chat-123', bold('Это жирный текст'));
424
+ // Отправит: **Это жирный текст**
425
+ ```
426
+
427
+ ### `italic(text)`
428
+
429
+ Оборачивает текст в курсивное форматирование.
430
+
431
+ **Параметры:**
432
+ - `text` — Текст для форматирования
433
+
434
+ **Возвращает:** `string` — Отформатированный текст с маркерами `__`
435
+
436
+ **Пример:**
437
+ ```typescript
438
+ await karbo.text('chat-123', italic('Это курсивный текст'));
439
+ // Отправит: __Это курсивный текст__
440
+ ```
441
+
442
+ ### `centralize(text)`
443
+
444
+ Выравнивает текст по центру сообщения.
445
+
446
+ **Параметры:**
447
+ - `text` — Текст для центрирования
448
+
449
+ **Возвращает:** `string` — Отформатированный текст с префиксом `[C]`
450
+
451
+ **Пример:**
452
+ ```typescript
453
+ await karbo.text('chat-123', centralize('Центрированный текст'));
454
+ // Отправит: [C]Центрированный текст
455
+ ```
456
+
457
+ ### `code(text)`
458
+
459
+ Оборачивает текст в inline-код форматирование.
460
+
461
+ **Параметры:**
462
+ - `text` — Текст для форматирования
463
+
464
+ **Возвращает:** `string` — Отформатированный текст с обратными кавычками
465
+
466
+ **Пример:**
467
+ ```typescript
468
+ await karbo.text('chat-123', code('const x = 42'));
469
+ // Отправит: `const x = 42`
470
+ ```
471
+
472
+ ### `strikethrough(text)`
473
+
474
+ Оборачивает текст в зачёркнутое форматирование.
475
+
476
+ **Параметры:**
477
+ - `text` — Текст для форматирования
478
+
479
+ **Возвращает:** `string` — Отформатированный текст с маркерами `~~`
480
+
481
+ **Пример:**
482
+ ```typescript
483
+ await karbo.text('chat-123', strikethrough('Это удалённый текст'));
484
+ // Отправит: ~~Это удалённый текст~~
485
+ ```
486
+
487
+ ### `underline(text)`
488
+
489
+ Оборачивает текст в подчёркнутое форматирование.
490
+
491
+ **Параметры:**
492
+ - `text` — Текст для форматирования
493
+
494
+ **Возвращает:** `string` — Отформатированный текст с маркерами `++`
495
+
496
+ **Пример:**
497
+ ```typescript
498
+ await karbo.text('chat-123', underline('Подчёркнутый текст'));
499
+ // Отправит: ++Подчёркнутый текст++
500
+ ```
501
+
502
+ ### `hyperlink(text, url)`
503
+
504
+ Создаёт гиперссылку с отображаемым текстом.
505
+
506
+ **Параметры:**
507
+ - `text` — Отображаемый текст ссылки
508
+ - `url` — URL для гиперссылки
509
+
510
+ **Возвращает:** `string` — Отформатированная гиперссылка
511
+
512
+ **Пример:**
513
+ ```typescript
514
+ await karbo.text('chat-123', hyperlink('Посетить KarboAI', 'https://karboai.com'));
515
+ // Отправит: [Посетить KarboAI](https://karboai.com)
516
+ ```
517
+
396
518
  ## Логирование
397
519
 
398
520
  Включите структурированное логирование, установив `enableLogging: true` в конфигурации:
package/README.md CHANGED
@@ -32,6 +32,14 @@ A powerful library for creating bots in the [KarboAI](https://karboai.com) appli
32
32
  - [on()](#on)
33
33
  - [command()](#command)
34
34
  - [Schemas](#schemas)
35
+ - [Utilities](#utilities)
36
+ - [bold()](#bold)
37
+ - [italic()](#italic)
38
+ - [centralize()](#centralize)
39
+ - [code()](#code)
40
+ - [strikethrough()](#strikethrough)
41
+ - [underline()](#underline)
42
+ - [hyperlink()](#hyperlink)
35
43
  - [Logging](#logging)
36
44
 
37
45
  ## Installation
@@ -393,6 +401,120 @@ The library exports several TypeScript types and Zod schemas:
393
401
  import { KarboConfig, Message, KarboContext, User } from 'karboai';
394
402
  ```
395
403
 
404
+ ## Utilities
405
+
406
+ Helper functions for formatting text in messages. All utilities are exported from the main package.
407
+
408
+ ```typescript
409
+ import { bold, italic, centralize, code, strikethrough, underline, hyperlink } from 'karboai';
410
+ ```
411
+
412
+ ### `bold(text)`
413
+
414
+ Wraps text in bold formatting.
415
+
416
+ **Parameters:**
417
+ - `text` — Text to format
418
+
419
+ **Returns:** `string` — Formatted text with `**` markers
420
+
421
+ **Example:**
422
+ ```typescript
423
+ await karbo.text('chat-123', bold('This is bold text'));
424
+ // Sends: **This is bold text**
425
+ ```
426
+
427
+ ### `italic(text)`
428
+
429
+ Wraps text in italic formatting.
430
+
431
+ **Parameters:**
432
+ - `text` — Text to format
433
+
434
+ **Returns:** `string` — Formatted text with `__` markers
435
+
436
+ **Example:**
437
+ ```typescript
438
+ await karbo.text('chat-123', italic('This is italic text'));
439
+ // Sends: __This is italic text__
440
+ ```
441
+
442
+ ### `centralize(text)`
443
+
444
+ Centers text in the message.
445
+
446
+ **Parameters:**
447
+ - `text` — Text to center
448
+
449
+ **Returns:** `string` — Formatted text with `[C]` prefix
450
+
451
+ **Example:**
452
+ ```typescript
453
+ await karbo.text('chat-123', centralize('Centered text'));
454
+ // Sends: [C]Centered text
455
+ ```
456
+
457
+ ### `code(text)`
458
+
459
+ Wraps text in inline code formatting.
460
+
461
+ **Parameters:**
462
+ - `text` — Text to format
463
+
464
+ **Returns:** `string` — Formatted text with backtick markers
465
+
466
+ **Example:**
467
+ ```typescript
468
+ await karbo.text('chat-123', code('const x = 42'));
469
+ // Sends: `const x = 42`
470
+ ```
471
+
472
+ ### `strikethrough(text)`
473
+
474
+ Wraps text in strikethrough formatting.
475
+
476
+ **Parameters:**
477
+ - `text` — Text to format
478
+
479
+ **Returns:** `string` — Formatted text with `~~` markers
480
+
481
+ **Example:**
482
+ ```typescript
483
+ await karbo.text('chat-123', strikethrough('This is deleted'));
484
+ // Sends: ~~This is deleted~~
485
+ ```
486
+
487
+ ### `underline(text)`
488
+
489
+ Wraps text in underline formatting.
490
+
491
+ **Parameters:**
492
+ - `text` — Text to format
493
+
494
+ **Returns:** `string` — Formatted text with `++` markers
495
+
496
+ **Example:**
497
+ ```typescript
498
+ await karbo.text('chat-123', underline('Underlined text'));
499
+ // Sends: ++Underlined text++
500
+ ```
501
+
502
+ ### `hyperlink(text, url)`
503
+
504
+ Creates a hyperlink with display text.
505
+
506
+ **Parameters:**
507
+ - `text` — Display text for the link
508
+ - `url` — URL for the hyperlink
509
+
510
+ **Returns:** `string` — Formatted hyperlink
511
+
512
+ **Example:**
513
+ ```typescript
514
+ await karbo.text('chat-123', hyperlink('Visit KarboAI', 'https://karboai.com'));
515
+ // Sends: [Visit KarboAI](https://karboai.com)
516
+ ```
517
+
396
518
  ## Logging
397
519
 
398
520
  Enable structured logging by setting `enableLogging: true` in the config:
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export { Router } from './core/hub/router';
2
2
  export { KarboAI } from './core/karboai';
3
+ export { bold, italic, centralize, code, strikethrough, underline, hyperlink, } from './utils/utils';
3
4
  export * from './schemas/index';
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEzC,cAAc,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EACL,IAAI,EACJ,MAAM,EACN,UAAU,EACV,IAAI,EACJ,aAAa,EACb,SAAS,EACT,SAAS,GACV,MAAM,eAAe,CAAC;AAEvB,cAAc,iBAAiB,CAAC"}
package/dist/index.js CHANGED
@@ -14,9 +14,17 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.KarboAI = exports.Router = void 0;
17
+ exports.hyperlink = exports.underline = exports.strikethrough = exports.code = exports.centralize = exports.italic = exports.bold = exports.KarboAI = exports.Router = void 0;
18
18
  var router_1 = require("./core/hub/router");
19
19
  Object.defineProperty(exports, "Router", { enumerable: true, get: function () { return router_1.Router; } });
20
20
  var karboai_1 = require("./core/karboai");
21
21
  Object.defineProperty(exports, "KarboAI", { enumerable: true, get: function () { return karboai_1.KarboAI; } });
22
+ var utils_1 = require("./utils/utils");
23
+ Object.defineProperty(exports, "bold", { enumerable: true, get: function () { return utils_1.bold; } });
24
+ Object.defineProperty(exports, "italic", { enumerable: true, get: function () { return utils_1.italic; } });
25
+ Object.defineProperty(exports, "centralize", { enumerable: true, get: function () { return utils_1.centralize; } });
26
+ Object.defineProperty(exports, "code", { enumerable: true, get: function () { return utils_1.code; } });
27
+ Object.defineProperty(exports, "strikethrough", { enumerable: true, get: function () { return utils_1.strikethrough; } });
28
+ Object.defineProperty(exports, "underline", { enumerable: true, get: function () { return utils_1.underline; } });
29
+ Object.defineProperty(exports, "hyperlink", { enumerable: true, get: function () { return utils_1.hyperlink; } });
22
30
  __exportStar(require("./schemas/index"), exports);
@@ -1,3 +1,10 @@
1
1
  export declare const clean: (body: Record<string, any>) => Record<string, any>;
2
2
  export declare const generateRouterName: () => string;
3
+ export declare const bold: (text: string) => string;
4
+ export declare const italic: (text: string) => string;
5
+ export declare const centralize: (text: string) => string;
6
+ export declare const code: (text: string) => string;
7
+ export declare const strikethrough: (text: string) => string;
8
+ export declare const underline: (text: string) => string;
9
+ export declare const hyperlink: (text: string, url: string) => string;
3
10
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils/utils.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,KAAK,GAAI,MAAM,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAGjE,CAAC;AAEJ,eAAO,MAAM,kBAAkB,QAAO,MACkB,CAAC"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils/utils.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,KAAK,GAAI,MAAM,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAGjE,CAAC;AAEJ,eAAO,MAAM,kBAAkB,QAAO,MACkB,CAAC;AAEzD,eAAO,MAAM,IAAI,GAAI,MAAM,MAAM,WAAkB,CAAC;AACpD,eAAO,MAAM,MAAM,GAAI,MAAM,MAAM,WAAkB,CAAC;AACtD,eAAO,MAAM,UAAU,GAAI,MAAM,MAAM,WAAiB,CAAC;AACzD,eAAO,MAAM,IAAI,GAAI,MAAM,MAAM,WAAkB,CAAC;AACpD,eAAO,MAAM,aAAa,GAAI,MAAM,MAAM,WAAkB,CAAC;AAC7D,eAAO,MAAM,SAAS,GAAI,MAAM,MAAM,WAAkB,CAAC;AACzD,eAAO,MAAM,SAAS,GAAI,MAAM,MAAM,EAAE,KAAK,MAAM,WAAwB,CAAC"}
@@ -1,7 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generateRouterName = exports.clean = void 0;
3
+ exports.hyperlink = exports.underline = exports.strikethrough = exports.code = exports.centralize = exports.italic = exports.bold = exports.generateRouterName = exports.clean = void 0;
4
4
  const clean = (body) => Object.fromEntries(Object.entries(body).filter(([_, value]) => value !== undefined));
5
5
  exports.clean = clean;
6
6
  const generateRouterName = () => `router-${Math.random().toString(36).substring(2, 9)}`;
7
7
  exports.generateRouterName = generateRouterName;
8
+ const bold = (text) => `**${text}**`;
9
+ exports.bold = bold;
10
+ const italic = (text) => `__${text}__`;
11
+ exports.italic = italic;
12
+ const centralize = (text) => `[C]${text}`;
13
+ exports.centralize = centralize;
14
+ const code = (text) => `\`${text}\``;
15
+ exports.code = code;
16
+ const strikethrough = (text) => `~~${text}~~`;
17
+ exports.strikethrough = strikethrough;
18
+ const underline = (text) => `++${text}++`;
19
+ exports.underline = underline;
20
+ const hyperlink = (text, url) => `[${text}](${url})`;
21
+ exports.hyperlink = hyperlink;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "karboai",
3
- "version": "1.6.0",
3
+ "version": "1.7.0",
4
4
  "description": "A powerful lib for https://karboai.com",
5
5
  "keywords": [
6
6
  "karbo",