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 +7 -6
- package/dist/index.d.ts +1 -0
- package/dist/index.js +7 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -28,16 +28,17 @@ npm install telekit-lib
|
|
|
28
28
|
## ⚡ Быстрый старт
|
|
29
29
|
|
|
30
30
|
```typescript
|
|
31
|
-
import { TeleKit
|
|
31
|
+
import { TeleKit } from 'telekit-lib';
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
const
|
|
33
|
+
// 1. Инициализация
|
|
34
|
+
const bot = new TeleKit('YOUR_BOT_TOKEN');
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
ctx.reply('
|
|
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;
|