telekit-lib 2.0.0 → 2.0.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/README.md CHANGED
@@ -28,16 +28,17 @@ npm install telekit-lib
28
28
  ## ⚡ Быстрый старт
29
29
 
30
30
  ```typescript
31
- import { TeleKit, LocalDB } from 'telekit-lib';
31
+ import { TeleKit } from 'telekit-lib';
32
32
 
33
- const bot = new TeleKit(process.env.TOKEN);
34
- const db = new LocalDB('users.json');
33
+ // 1. Инициализация
34
+ const bot = new TeleKit('YOUR_BOT_TOKEN');
35
35
 
36
- bot.command('start', (ctx) => {
37
- db.push({ id: ctx.from.id, name: ctx.from.first_name });
38
- ctx.reply('Добро пожаловать в TeleKit!');
36
+ // 2. Простая команда
37
+ bot.command('start', async (ctx) => {
38
+ await ctx.reply('Привет! Бот успешно запущен.');
39
39
  });
40
40
 
41
+ // 3. Запуск
41
42
  bot.start();
42
43
  ```
43
44
 
package/dist/index.d.ts CHANGED
@@ -71,6 +71,7 @@ export declare class Context {
71
71
  get chatId(): number | undefined;
72
72
  get from(): User | undefined;
73
73
  get text(): string | undefined;
74
+ get userId(): number | undefined;
74
75
  get callbackData(): string | undefined;
75
76
  reply(text: string, extra?: any): Promise<any>;
76
77
  answerCallback(text?: string, alert?: boolean): Promise<any>;
package/dist/index.js CHANGED
@@ -197,6 +197,13 @@ class Context {
197
197
  return this.update.message.text;
198
198
  return undefined;
199
199
  }
200
+ get userId() {
201
+ if ('message' in this.update)
202
+ return this.update.message.from?.id;
203
+ if ('callback_query' in this.update)
204
+ return this.update.callback_query.from.id;
205
+ return undefined;
206
+ }
200
207
  get callbackData() {
201
208
  if ('callback_query' in this.update && 'data' in this.update.callback_query)
202
209
  return this.update.callback_query.data;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "telekit-lib",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "Профессиональный TypeScript фреймворк для Telegram ботов со встроенной LocalDB",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",