chz-telegram-bot 0.0.53 → 0.1.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.md +205 -0
- package/dist/helpers/traceFactory.d.ts.map +1 -1
- package/dist/types/timeValues.d.ts +7 -3
- package/dist/types/timeValues.d.ts.map +1 -1
- package/dist/types/trace.d.ts +5 -1
- package/dist/types/trace.d.ts.map +1 -1
- package/helpers/traceFactory.ts +2 -2
- package/package.json +1 -1
- package/types/timeValues.ts +7 -3
- package/types/trace.ts +3 -1
- package/dist/dtos/actionExecutionResult.d.ts +0 -7
- package/dist/dtos/actionExecutionResult.d.ts.map +0 -1
- package/dist/dtos/actionExecutionResult.js +0 -10
- package/dist/entities/actionExecutionResult.d.ts +0 -7
- package/dist/entities/actionExecutionResult.d.ts.map +0 -1
- package/dist/entities/actionExecutionResult.js +0 -10
- package/dist/entities/commandTriggerCheckResult.d.ts +0 -10
- package/dist/entities/commandTriggerCheckResult.d.ts.map +0 -1
- package/dist/entities/commandTriggerCheckResult.js +0 -23
- package/dist/entities/incomingMessage.d.ts +0 -14
- package/dist/entities/incomingMessage.d.ts.map +0 -1
- package/dist/entities/incomingMessage.js +0 -45
- package/dist/entities/responses/delay.d.ts +0 -13
- package/dist/entities/responses/delay.d.ts.map +0 -1
- package/dist/entities/responses/delay.js +0 -14
- package/dist/entities/responses/imageMessage.d.ts +0 -17
- package/dist/entities/responses/imageMessage.d.ts.map +0 -1
- package/dist/entities/responses/imageMessage.js +0 -17
- package/dist/entities/responses/reaction.d.ts +0 -14
- package/dist/entities/responses/reaction.d.ts.map +0 -1
- package/dist/entities/responses/reaction.js +0 -15
- package/dist/entities/responses/textMessage.d.ts +0 -16
- package/dist/entities/responses/textMessage.d.ts.map +0 -1
- package/dist/entities/responses/textMessage.js +0 -17
- package/dist/entities/responses/unpin.d.ts +0 -12
- package/dist/entities/responses/unpin.d.ts.map +0 -1
- package/dist/entities/responses/unpin.js +0 -14
- package/dist/entities/responses/videoMessage.d.ts +0 -17
- package/dist/entities/responses/videoMessage.d.ts.map +0 -1
- package/dist/entities/responses/videoMessage.js +0 -17
- package/dist/helpers/inverseRecord.d.ts +0 -2
- package/dist/helpers/inverseRecord.d.ts.map +0 -1
- package/dist/helpers/inverseRecord.js +0 -6
- package/dist/helpers/reverseMap.d.ts +0 -2
- package/dist/helpers/reverseMap.d.ts.map +0 -1
- package/dist/helpers/reverseMap.js +0 -6
- package/dist/helpers/reverseRecord.d.ts +0 -2
- package/dist/helpers/reverseRecord.d.ts.map +0 -1
- package/dist/helpers/reverseRecord.js +0 -6
- package/dist/services/logger.d.ts +0 -9
- package/dist/services/logger.d.ts.map +0 -1
- package/dist/services/logger.js +0 -28
- package/dist/services/taskScheduler.d.ts +0 -11
- package/dist/services/taskScheduler.d.ts.map +0 -1
- package/dist/services/taskScheduler.js +0 -33
- package/dist/types/daysOfTheWeek.d.ts +0 -10
- package/dist/types/daysOfTheWeek.d.ts.map +0 -1
- package/dist/types/daysOfTheWeek.js +0 -13
- package/dist/types/replyMessage.d.ts +0 -8
- package/dist/types/replyMessage.d.ts.map +0 -1
- package/dist/types/replyMessage.js +0 -2
package/README.md
ADDED
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
|
|
2
|
+
# chz-bot-Framework
|
|
3
|
+
|
|
4
|
+
[](https://deepwiki.com/AlexSolari/botFramework)
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
botFramework is a TypeScript library that provides a structured approach to building Telegram bots. It handles the complexities of bot lifecycle management, message processing, scheduled tasks, and state persistence.
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
npm install chz-bot-framework
|
|
13
|
+
# or
|
|
14
|
+
bun install chz-bot-framework
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Quick Start
|
|
18
|
+
|
|
19
|
+
### 1. Create a new bot project
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
mkdir my-telegram-bot
|
|
23
|
+
cd my-telegram-bot
|
|
24
|
+
npm init -y
|
|
25
|
+
npm install chz-telegram-bot
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### 2. Create a token file
|
|
29
|
+
|
|
30
|
+
Create a file named `token.txt` in your project and paste your Telegram Bot token obtained from BotFather.
|
|
31
|
+
|
|
32
|
+
### 3. Create a basic bot
|
|
33
|
+
|
|
34
|
+
Create an `index.ts` file with the following content:
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
import { startBot, stopBots, CommandActionBuilder, Seconds } from 'chz-telegram-bot';
|
|
38
|
+
|
|
39
|
+
// Define your command actions
|
|
40
|
+
const commands = [
|
|
41
|
+
new CommandActionBuilder('HelloWorld')
|
|
42
|
+
.on('/hello')
|
|
43
|
+
.do(async (ctx) => {
|
|
44
|
+
ctx.replyWithText('Hello, world!');
|
|
45
|
+
})
|
|
46
|
+
.build()
|
|
47
|
+
];
|
|
48
|
+
|
|
49
|
+
// Define scheduled actions (if needed)
|
|
50
|
+
const scheduled = [];
|
|
51
|
+
|
|
52
|
+
async function main() {
|
|
53
|
+
// Start the bot
|
|
54
|
+
startBot({
|
|
55
|
+
name: 'MyFirstBot',
|
|
56
|
+
tokenFilePath: './token.txt',
|
|
57
|
+
commands: commands,
|
|
58
|
+
scheduled: scheduled,
|
|
59
|
+
chats: {
|
|
60
|
+
MyChat: -1001234567890 // Replace with your actual chat ID,
|
|
61
|
+
},
|
|
62
|
+
scheduledPeriod: (60 * 5) as Seconds
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
// Set up graceful shutdown
|
|
66
|
+
process.on('SIGINT', () => stopBots('SIGINT'));
|
|
67
|
+
process.on('SIGTERM', () => stopBots('SIGTERM'));
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
main().catch(console.error);
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### 4. Run your bot
|
|
74
|
+
|
|
75
|
+
```
|
|
76
|
+
bun index.ts
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Core Concepts
|
|
80
|
+
|
|
81
|
+
### Command Actions
|
|
82
|
+
|
|
83
|
+
Command actions are triggered by user messages that match specific patterns:
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
import { CommandActionBuilder } from 'chz-telegram-bot';
|
|
87
|
+
|
|
88
|
+
const myCommand = new CommandActionBuilder('StartCommand')
|
|
89
|
+
.on('/start')
|
|
90
|
+
.do(async (ctx) => {
|
|
91
|
+
ctx.replyWithText('Welcome to my bot!');
|
|
92
|
+
})
|
|
93
|
+
.build();
|
|
94
|
+
```
|
|
95
|
+
Message types are also can trigger commands:
|
|
96
|
+
```typescript
|
|
97
|
+
import { CommandActionBuilder, MessageType } from 'chz-telegram-bot';
|
|
98
|
+
|
|
99
|
+
const myCommand = new CommandActionBuilder('WelcomeMessage')
|
|
100
|
+
.on(MessageType.NewChatMember)
|
|
101
|
+
.do(async (ctx) => {
|
|
102
|
+
ctx.replyWithText('Welcome to my group chat!');
|
|
103
|
+
})
|
|
104
|
+
.build();
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Scheduled Actions
|
|
108
|
+
|
|
109
|
+
Scheduled actions run periodically without user interaction:
|
|
110
|
+
|
|
111
|
+
```typescript
|
|
112
|
+
import { ScheduledActionBuilder, Hours } from 'chz-telegram-bot';
|
|
113
|
+
|
|
114
|
+
const dailyNotification = new ScheduledActionBuilder('GM')
|
|
115
|
+
.runAt(9 as Hours) // Run at 9 AM
|
|
116
|
+
.do(async (ctx) => {
|
|
117
|
+
await ctx.sendTextToChat('Good morning!');
|
|
118
|
+
})
|
|
119
|
+
.build();
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Replies and message sending
|
|
123
|
+
Depending on a type of action, you will have access to following interaction options:
|
|
124
|
+
|
|
125
|
+
| Method | Action type | Description
|
|
126
|
+
|----------|----------------|-------
|
|
127
|
+
|`sendTextToChat`|Both|Send text to chat as a standalone message
|
|
128
|
+
|`sendImageToChat`|Both|Send image to chat as a standalone message
|
|
129
|
+
|`sendVideoToChat`|Both|Send video/gif to chat as a standalone message
|
|
130
|
+
|`unpinMessage`|Both|Unpins message by its ID
|
|
131
|
+
|`delayNextResponse`|Both|Delays next reply action my given amount of ms
|
|
132
|
+
|`replyWithText`|Command|Replies with text to a message that triggered an action
|
|
133
|
+
|`replyWithImage`|Command|Replies with image to a message that triggered an action
|
|
134
|
+
|`replyWithVideo`|Command|Replies with video/gif to a message that triggered an action
|
|
135
|
+
|`react`|Command|Sets an emoji reaction to a message that triggered an action
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
Keep in mind that reply sending is deferred until action execution finished and will be done in order of calling in action handler.
|
|
139
|
+
Ex:
|
|
140
|
+
```typescript
|
|
141
|
+
ctx.sendTextToChat('Message 1')
|
|
142
|
+
ctx.delayNextResponse(5000 as Millisecond)
|
|
143
|
+
ctx.sendTextToChat('Message 2')
|
|
144
|
+
```
|
|
145
|
+
This will result in `Message 1` text being send, followed by `Message 2` after 5 second delay.
|
|
146
|
+
|
|
147
|
+
## Configuration Options
|
|
148
|
+
|
|
149
|
+
When starting a bot, you can provide the following configuration:
|
|
150
|
+
|
|
151
|
+
| Option | Type | Required | Description |
|
|
152
|
+
|------------------|--------------------------|----------|---------------------------------------------------------------|
|
|
153
|
+
| `name` | `string` | Yes | Bot name used in logging |
|
|
154
|
+
| `tokenFilePath` | `string` | Yes | Path to file containing Telegram Bot token |
|
|
155
|
+
| `commands` | `CommandAction[] ` | Yes (can be empty) | Collection of command actions |
|
|
156
|
+
| `scheduled` | `ScheduledAction[]` | Yes (can be empty) | Collection of scheduled actions |
|
|
157
|
+
| `chats` | `Record<string, number>` | Yes | Object containing chat name-id pairs. Used for logging and execution of scheduled action. |
|
|
158
|
+
| `storagePath` | `string` | No | Custom storage path for default JsonFileStorage client |
|
|
159
|
+
| `scheduledPeriod`| `Seconds` | No (will default to 1 hour) | Period between scheduled action executions |
|
|
160
|
+
| `services` | | No | Custom services to be used instead of default ones |
|
|
161
|
+
|
|
162
|
+
Services object should have following structure:
|
|
163
|
+
| Option | Type | Required | Description |
|
|
164
|
+
|------------------|--------------------------|----------|---------------------------------------------------------------|
|
|
165
|
+
| `storageClient` | `IStorageClient` | No (will default to `JsonFileStorage`) | Persistance state provide |
|
|
166
|
+
| `logger` | `ILogger` | No (will default to `JsonLogger`) | Logger service |
|
|
167
|
+
| `scheduler` | `IScheduler` | No (will default to `NodeTimeoutScheduler`) | Scheduler used to scheduled action|
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
## Advanced Usage
|
|
171
|
+
|
|
172
|
+
### Custom State Management
|
|
173
|
+
|
|
174
|
+
The framework allows you to create custom state for your actions:
|
|
175
|
+
|
|
176
|
+
```typescript
|
|
177
|
+
import { ActionStateBase } from 'chz-telegram-bot';
|
|
178
|
+
|
|
179
|
+
class MyCustomState extends ActionStateBase {
|
|
180
|
+
counter: number = 0;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const counterCommand = new CommandActionBuilderWithState<MyCustomState>(
|
|
184
|
+
'Counter',
|
|
185
|
+
() => new MyCustomState()
|
|
186
|
+
)
|
|
187
|
+
.on('/count')
|
|
188
|
+
.do(async (ctx, state) => {
|
|
189
|
+
state.counter++;
|
|
190
|
+
await ctx.replyWithText(`Count: ${state.counter}`);
|
|
191
|
+
})
|
|
192
|
+
.build();
|
|
193
|
+
```
|
|
194
|
+
State is mutable and all changes to it will be saved after execution of action is finished.
|
|
195
|
+
|
|
196
|
+
## Stopping the Bot
|
|
197
|
+
|
|
198
|
+
To properly terminate your bot and clean up resources:
|
|
199
|
+
|
|
200
|
+
```typescript
|
|
201
|
+
import { stopBots } from 'chz-telegram-bot';
|
|
202
|
+
|
|
203
|
+
// Call when your application is shutting down
|
|
204
|
+
await stopBots('SHUTDOWN');
|
|
205
|
+
```
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"traceFactory.d.ts","sourceRoot":"","sources":["../../helpers/traceFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEzC,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAAM,EACxC,UAAU,EAAE,CAAC,EACb,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"traceFactory.d.ts","sourceRoot":"","sources":["../../helpers/traceFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEzC,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAAM,EACxC,UAAU,EAAE,CAAC,EACb,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,GAEkD,OAAO,CAC7E"}
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
+
declare const millisecondsSymbol: unique symbol;
|
|
2
|
+
declare const secondsSymbol: unique symbol;
|
|
3
|
+
declare const hoursSymbol: unique symbol;
|
|
1
4
|
export type Milliseconds = number & {
|
|
2
|
-
|
|
5
|
+
[millisecondsSymbol]: void;
|
|
3
6
|
};
|
|
4
7
|
export type Seconds = number & {
|
|
5
|
-
|
|
8
|
+
[secondsSymbol]: void;
|
|
6
9
|
};
|
|
7
10
|
export type Hours = number & {
|
|
8
|
-
|
|
11
|
+
[hoursSymbol]: void;
|
|
9
12
|
};
|
|
10
13
|
export type HoursOfDay = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23;
|
|
14
|
+
export {};
|
|
11
15
|
//# sourceMappingURL=timeValues.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timeValues.d.ts","sourceRoot":"","sources":["../../types/timeValues.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG;IAAE,
|
|
1
|
+
{"version":3,"file":"timeValues.d.ts","sourceRoot":"","sources":["../../types/timeValues.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,kBAAkB,EAAE,OAAO,MAAM,CAAC;AAChD,OAAO,CAAC,MAAM,aAAa,EAAE,OAAO,MAAM,CAAC;AAC3C,OAAO,CAAC,MAAM,WAAW,EAAE,OAAO,MAAM,CAAC;AAEzC,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG;IAAE,CAAC,kBAAkB,CAAC,EAAE,IAAI,CAAA;CAAE,CAAC;AACnE,MAAM,MAAM,OAAO,GAAG,MAAM,GAAG;IAAE,CAAC,aAAa,CAAC,EAAE,IAAI,CAAA;CAAE,CAAC;AACzD,MAAM,MAAM,KAAK,GAAG,MAAM,GAAG;IAAE,CAAC,WAAW,CAAC,EAAE,IAAI,CAAA;CAAE,CAAC;AAErD,MAAM,MAAM,UAAU,GAChB,CAAC,GACD,CAAC,GACD,CAAC,GACD,CAAC,GACD,CAAC,GACD,CAAC,GACD,CAAC,GACD,CAAC,GACD,CAAC,GACD,CAAC,GACD,EAAE,GACF,EAAE,GACF,EAAE,GACF,EAAE,GACF,EAAE,GACF,EAAE,GACF,EAAE,GACF,EAAE,GACF,EAAE,GACF,EAAE,GACF,EAAE,GACF,EAAE,GACF,EAAE,GACF,EAAE,CAAC"}
|
package/dist/types/trace.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trace.d.ts","sourceRoot":"","sources":["../../types/trace.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,OAAO,GAAG,GAAG,MAAM,IAAI,MAAM,IAAI,MAAM,EAAE,CAAC"}
|
|
1
|
+
{"version":3,"file":"trace.d.ts","sourceRoot":"","sources":["../../types/trace.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,WAAW,EAAE,OAAO,MAAM,CAAC;AAEzC,MAAM,MAAM,OAAO,GAAG,GAAG,MAAM,IAAI,MAAM,IAAI,MAAM,EAAE,GAAG;IAAE,CAAC,WAAW,CAAC,EAAE,IAAI,CAAA;CAAE,CAAC"}
|
package/helpers/traceFactory.ts
CHANGED
|
@@ -4,6 +4,6 @@ export function createTrace<T extends object>(
|
|
|
4
4
|
traceOwner: T,
|
|
5
5
|
botName: string,
|
|
6
6
|
traceName: string
|
|
7
|
-
)
|
|
8
|
-
return `${traceOwner.constructor.name}:${botName}-${traceName}
|
|
7
|
+
) {
|
|
8
|
+
return `${traceOwner.constructor.name}:${botName}-${traceName}` as TraceId;
|
|
9
9
|
}
|
package/package.json
CHANGED
package/types/timeValues.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
declare const millisecondsSymbol: unique symbol;
|
|
2
|
+
declare const secondsSymbol: unique symbol;
|
|
3
|
+
declare const hoursSymbol: unique symbol;
|
|
4
|
+
|
|
5
|
+
export type Milliseconds = number & { [millisecondsSymbol]: void };
|
|
6
|
+
export type Seconds = number & { [secondsSymbol]: void };
|
|
7
|
+
export type Hours = number & { [hoursSymbol]: void };
|
|
4
8
|
|
|
5
9
|
export type HoursOfDay =
|
|
6
10
|
| 0
|
package/types/trace.ts
CHANGED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { IActionState } from '../types/actionState';
|
|
2
|
-
export declare class ActionExecutionResult<TActionState extends IActionState> {
|
|
3
|
-
readonly data: TActionState;
|
|
4
|
-
readonly shouldUpdate: boolean;
|
|
5
|
-
constructor(data: TActionState, shouldUpdate: boolean);
|
|
6
|
-
}
|
|
7
|
-
//# sourceMappingURL=actionExecutionResult.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"actionExecutionResult.d.ts","sourceRoot":"","sources":["../../dtos/actionExecutionResult.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD,qBAAa,qBAAqB,CAAC,YAAY,SAAS,YAAY;IAChE,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAC5B,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;gBAEnB,IAAI,EAAE,YAAY,EAAE,YAAY,EAAE,OAAO;CAIxD"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ActionExecutionResult = void 0;
|
|
4
|
-
class ActionExecutionResult {
|
|
5
|
-
constructor(data, shouldUpdate) {
|
|
6
|
-
this.data = data;
|
|
7
|
-
this.shouldUpdate = shouldUpdate;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
exports.ActionExecutionResult = ActionExecutionResult;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { IActionState } from '../types/actionState';
|
|
2
|
-
export declare class ActionExecutionResult<TActionState extends IActionState> {
|
|
3
|
-
data: TActionState;
|
|
4
|
-
shouldUpdate: boolean;
|
|
5
|
-
constructor(data: TActionState, shouldUpdate: boolean);
|
|
6
|
-
}
|
|
7
|
-
//# sourceMappingURL=actionExecutionResult.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"actionExecutionResult.d.ts","sourceRoot":"","sources":["../../entities/actionExecutionResult.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD,qBAAa,qBAAqB,CAAC,YAAY,SAAS,YAAY;IAChE,IAAI,EAAE,YAAY,CAAC;IACnB,YAAY,EAAE,OAAO,CAAC;gBAEV,IAAI,EAAE,YAAY,EAAE,YAAY,EAAE,OAAO;CAIxD"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ActionExecutionResult = void 0;
|
|
4
|
-
class ActionExecutionResult {
|
|
5
|
-
constructor(data, shouldUpdate) {
|
|
6
|
-
this.data = data;
|
|
7
|
-
this.shouldUpdate = shouldUpdate;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
exports.ActionExecutionResult = ActionExecutionResult;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export declare class CommandTriggerCheckResult {
|
|
2
|
-
static get DontTriggerAndSkipCooldown(): CommandTriggerCheckResult;
|
|
3
|
-
static get DoNotTrigger(): CommandTriggerCheckResult;
|
|
4
|
-
shouldTrigger: boolean;
|
|
5
|
-
matchResults: RegExpExecArray[];
|
|
6
|
-
skipCooldown: boolean;
|
|
7
|
-
constructor(shouldTrigger: boolean, matchResults: RegExpExecArray[], skipCooldown: boolean);
|
|
8
|
-
mergeWith(other: CommandTriggerCheckResult): this;
|
|
9
|
-
}
|
|
10
|
-
//# sourceMappingURL=commandTriggerCheckResult.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"commandTriggerCheckResult.d.ts","sourceRoot":"","sources":["../../entities/commandTriggerCheckResult.ts"],"names":[],"mappings":"AAAA,qBAAa,yBAAyB;IAClC,MAAM,KAAK,0BAA0B,8BAEpC;IACD,MAAM,KAAK,YAAY,8BAEtB;IAED,aAAa,EAAE,OAAO,CAAC;IACvB,YAAY,EAAE,eAAe,EAAE,CAAC;IAChC,YAAY,EAAE,OAAO,CAAC;gBAGlB,aAAa,EAAE,OAAO,EACtB,YAAY,EAAE,eAAe,EAAE,EAC/B,YAAY,EAAE,OAAO;IAOzB,SAAS,CAAC,KAAK,EAAE,yBAAyB;CAO7C"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CommandTriggerCheckResult = void 0;
|
|
4
|
-
class CommandTriggerCheckResult {
|
|
5
|
-
static get DontTriggerAndSkipCooldown() {
|
|
6
|
-
return new CommandTriggerCheckResult(false, [], true);
|
|
7
|
-
}
|
|
8
|
-
static get DoNotTrigger() {
|
|
9
|
-
return new CommandTriggerCheckResult(false, [], false);
|
|
10
|
-
}
|
|
11
|
-
constructor(shouldTrigger, matchResults, skipCooldown) {
|
|
12
|
-
this.shouldTrigger = shouldTrigger;
|
|
13
|
-
this.matchResults = matchResults;
|
|
14
|
-
this.skipCooldown = skipCooldown;
|
|
15
|
-
}
|
|
16
|
-
mergeWith(other) {
|
|
17
|
-
this.shouldTrigger = this.shouldTrigger || other.shouldTrigger;
|
|
18
|
-
this.matchResults = this.matchResults.concat(other.matchResults);
|
|
19
|
-
this.skipCooldown = this.skipCooldown || other.skipCooldown;
|
|
20
|
-
return this;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
exports.CommandTriggerCheckResult = CommandTriggerCheckResult;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { Chat, Message, Update, User } from 'telegraf/types';
|
|
2
|
-
import { MessageTypeValue } from '../types/messageTypes';
|
|
3
|
-
export declare class IncomingMessage {
|
|
4
|
-
message_id: number;
|
|
5
|
-
chat: Chat;
|
|
6
|
-
from: User | undefined;
|
|
7
|
-
text: string;
|
|
8
|
-
chatName: string;
|
|
9
|
-
type: MessageTypeValue;
|
|
10
|
-
traceId: number;
|
|
11
|
-
private detectMessageType;
|
|
12
|
-
constructor(ctxMessage: Update.New & (Update.NonChannel & Message));
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=incomingMessage.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"incomingMessage.d.ts","sourceRoot":"","sources":["../../entities/incomingMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAE7D,OAAO,EAAe,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEtE,qBAAa,eAAe;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,IAAI,CAAC;IACX,IAAI,EAAE,IAAI,GAAG,SAAS,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,gBAAgB,CAAC;IACvB,OAAO,SAA2B;IAElC,OAAO,CAAC,iBAAiB;gBAkBb,UAAU,EAAE,MAAM,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,UAAU,GAAG,OAAO,CAAC;CAWrE"}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.IncomingMessage = void 0;
|
|
4
|
-
const crypto_1 = require("crypto");
|
|
5
|
-
const messageTypes_1 = require("../types/messageTypes");
|
|
6
|
-
class IncomingMessage {
|
|
7
|
-
detectMessageType(message) {
|
|
8
|
-
if ('text' in message)
|
|
9
|
-
return messageTypes_1.MessageType.Text;
|
|
10
|
-
if ('photo' in message)
|
|
11
|
-
return messageTypes_1.MessageType.Photo;
|
|
12
|
-
if ('sticker' in message)
|
|
13
|
-
return messageTypes_1.MessageType.Sticker;
|
|
14
|
-
if ('animation' in message)
|
|
15
|
-
return messageTypes_1.MessageType.Animation;
|
|
16
|
-
if ('voice' in message)
|
|
17
|
-
return messageTypes_1.MessageType.Voice;
|
|
18
|
-
if ('audio' in message)
|
|
19
|
-
return messageTypes_1.MessageType.Audio;
|
|
20
|
-
if ('document' in message)
|
|
21
|
-
return messageTypes_1.MessageType.Document;
|
|
22
|
-
if ('left_chat_member' in message)
|
|
23
|
-
return messageTypes_1.MessageType.LeftChatMember;
|
|
24
|
-
if ('new_chat_member' in message)
|
|
25
|
-
return messageTypes_1.MessageType.NewChatMember;
|
|
26
|
-
if ('poll' in message)
|
|
27
|
-
return messageTypes_1.MessageType.Poll;
|
|
28
|
-
if ('location' in message)
|
|
29
|
-
return messageTypes_1.MessageType.Location;
|
|
30
|
-
return messageTypes_1.MessageType.Unknown;
|
|
31
|
-
}
|
|
32
|
-
constructor(ctxMessage) {
|
|
33
|
-
this.traceId = (0, crypto_1.randomInt)(10000, 99999);
|
|
34
|
-
this.message_id = ctxMessage.message_id;
|
|
35
|
-
this.chat = ctxMessage.chat;
|
|
36
|
-
this.from = ctxMessage.from;
|
|
37
|
-
this.text = 'text' in ctxMessage ? ctxMessage.text : '';
|
|
38
|
-
this.type = this.detectMessageType(ctxMessage);
|
|
39
|
-
this.chatName =
|
|
40
|
-
'title' in ctxMessage.chat
|
|
41
|
-
? ctxMessage.chat.title + ' ' + ctxMessage.chat.id
|
|
42
|
-
: 'DM';
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
exports.IncomingMessage = IncomingMessage;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { IActionState } from '../../types/actionState';
|
|
2
|
-
import { IActionWithState } from '../../types/actionWithState';
|
|
3
|
-
import { IChatResponse } from '../../types/response';
|
|
4
|
-
import { Milliseconds } from '../../types/timeValues';
|
|
5
|
-
export declare class DelayResponse implements IChatResponse {
|
|
6
|
-
kind: "delay";
|
|
7
|
-
chatId: number;
|
|
8
|
-
traceId: number | string;
|
|
9
|
-
delay: Milliseconds;
|
|
10
|
-
action: IActionWithState<IActionState>;
|
|
11
|
-
constructor(delay: Milliseconds, chatId: number, traceId: number | string, action: IActionWithState<IActionState>);
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=delay.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"delay.d.ts","sourceRoot":"","sources":["../../../entities/responses/delay.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAoB,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD,qBAAa,aAAc,YAAW,aAAa;IAC/C,IAAI,UAA0B;IAE9B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,KAAK,EAAE,YAAY,CAAC;IACpB,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC;gBAGnC,KAAK,EAAE,YAAY,EACnB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,GAAG,MAAM,EACxB,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC;CAO7C"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DelayResponse = void 0;
|
|
4
|
-
const response_1 = require("../../types/response");
|
|
5
|
-
class DelayResponse {
|
|
6
|
-
constructor(delay, chatId, traceId, action) {
|
|
7
|
-
this.kind = response_1.BotResponseTypes.delay;
|
|
8
|
-
this.chatId = chatId;
|
|
9
|
-
this.delay = delay;
|
|
10
|
-
this.traceId = traceId;
|
|
11
|
-
this.action = action;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
exports.DelayResponse = DelayResponse;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { InputFile } from 'telegraf/types';
|
|
2
|
-
import { IReplyMessage } from '../../types/response';
|
|
3
|
-
import { MessageSendingOptions } from '../../types/messageSendingOptions';
|
|
4
|
-
import { IActionWithState } from '../../types/actionWithState';
|
|
5
|
-
import { IActionState } from '../../types/actionState';
|
|
6
|
-
export declare class ImageMessage implements IReplyMessage<InputFile> {
|
|
7
|
-
kind: "image";
|
|
8
|
-
content: InputFile;
|
|
9
|
-
chatId: number;
|
|
10
|
-
replyId: number | undefined;
|
|
11
|
-
traceId: string | number;
|
|
12
|
-
disableWebPreview: boolean;
|
|
13
|
-
shouldPin: boolean;
|
|
14
|
-
action: IActionWithState<IActionState>;
|
|
15
|
-
constructor(image: InputFile, chatId: number, replyId: number | undefined, traceId: number | string, action: IActionWithState<IActionState>, options?: MessageSendingOptions);
|
|
16
|
-
}
|
|
17
|
-
//# sourceMappingURL=imageMessage.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"imageMessage.d.ts","sourceRoot":"","sources":["../../../entities/responses/imageMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAoB,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,qBAAa,YAAa,YAAW,aAAa,CAAC,SAAS,CAAC;IACzD,IAAI,UAA0B;IAE9B,OAAO,EAAE,SAAS,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,iBAAiB,UAAS;IAC1B,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC;gBAGnC,KAAK,EAAE,SAAS,EAChB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,OAAO,EAAE,MAAM,GAAG,MAAM,EACxB,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC,EACtC,OAAO,CAAC,EAAE,qBAAqB;CAStC"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ImageMessage = void 0;
|
|
4
|
-
const response_1 = require("../../types/response");
|
|
5
|
-
class ImageMessage {
|
|
6
|
-
constructor(image, chatId, replyId, traceId, action, options) {
|
|
7
|
-
this.kind = response_1.BotResponseTypes.image;
|
|
8
|
-
this.disableWebPreview = false;
|
|
9
|
-
this.content = image;
|
|
10
|
-
this.chatId = chatId;
|
|
11
|
-
this.replyId = replyId;
|
|
12
|
-
this.traceId = traceId;
|
|
13
|
-
this.shouldPin = options?.pin ?? false;
|
|
14
|
-
this.action = action;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
exports.ImageMessage = ImageMessage;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { TelegramEmoji } from 'telegraf/types';
|
|
2
|
-
import { IChatResponse } from '../../types/response';
|
|
3
|
-
import { IActionWithState } from '../../types/actionWithState';
|
|
4
|
-
import { IActionState } from '../../types/actionState';
|
|
5
|
-
export declare class Reaction implements IChatResponse {
|
|
6
|
-
kind: "react";
|
|
7
|
-
chatId: number;
|
|
8
|
-
messageId: number;
|
|
9
|
-
traceId: number | string;
|
|
10
|
-
emoji: TelegramEmoji;
|
|
11
|
-
action: IActionWithState<IActionState>;
|
|
12
|
-
constructor(traceId: number | string, chatId: number, messageId: number, emoji: TelegramEmoji, action: IActionWithState<IActionState>);
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=reaction.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"reaction.d.ts","sourceRoot":"","sources":["../../../entities/responses/reaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAoB,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,qBAAa,QAAS,YAAW,aAAa;IAC1C,IAAI,UAA0B;IAE9B,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,KAAK,EAAE,aAAa,CAAC;IACrB,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC;gBAGnC,OAAO,EAAE,MAAM,GAAG,MAAM,EACxB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,aAAa,EACpB,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC;CAQ7C"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Reaction = void 0;
|
|
4
|
-
const response_1 = require("../../types/response");
|
|
5
|
-
class Reaction {
|
|
6
|
-
constructor(traceId, chatId, messageId, emoji, action) {
|
|
7
|
-
this.kind = response_1.BotResponseTypes.react;
|
|
8
|
-
this.chatId = chatId;
|
|
9
|
-
this.messageId = messageId;
|
|
10
|
-
this.emoji = emoji;
|
|
11
|
-
this.traceId = traceId;
|
|
12
|
-
this.action = action;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
exports.Reaction = Reaction;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { TextMessageSendingOptions } from '../../types/messageSendingOptions';
|
|
2
|
-
import { IReplyMessage } from '../../types/response';
|
|
3
|
-
import { IActionWithState } from '../../types/actionWithState';
|
|
4
|
-
import { IActionState } from '../../types/actionState';
|
|
5
|
-
export declare class TextMessage implements IReplyMessage<string> {
|
|
6
|
-
kind: "text";
|
|
7
|
-
content: string;
|
|
8
|
-
chatId: number;
|
|
9
|
-
replyId: number | undefined;
|
|
10
|
-
traceId: string | number;
|
|
11
|
-
disableWebPreview: boolean;
|
|
12
|
-
shouldPin: boolean;
|
|
13
|
-
action: IActionWithState<IActionState>;
|
|
14
|
-
constructor(text: string, chatId: number, replyId: number | undefined, traceId: string | number, action: IActionWithState<IActionState>, options?: TextMessageSendingOptions);
|
|
15
|
-
}
|
|
16
|
-
//# sourceMappingURL=textMessage.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"textMessage.d.ts","sourceRoot":"","sources":["../../../entities/responses/textMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAC9E,OAAO,EAAoB,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,qBAAa,WAAY,YAAW,aAAa,CAAC,MAAM,CAAC;IACrD,IAAI,SAAyB;IAE7B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC;gBAGnC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,OAAO,EAAE,MAAM,GAAG,MAAM,EACxB,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC,EACtC,OAAO,CAAC,EAAE,yBAAyB;CAU1C"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TextMessage = void 0;
|
|
4
|
-
const response_1 = require("../../types/response");
|
|
5
|
-
class TextMessage {
|
|
6
|
-
constructor(text, chatId, replyId, traceId, action, options) {
|
|
7
|
-
this.kind = response_1.BotResponseTypes.text;
|
|
8
|
-
this.content = text;
|
|
9
|
-
this.chatId = chatId;
|
|
10
|
-
this.replyId = replyId;
|
|
11
|
-
this.traceId = traceId;
|
|
12
|
-
this.disableWebPreview = options?.disableWebPreview ?? false;
|
|
13
|
-
this.shouldPin = options?.pin ?? false;
|
|
14
|
-
this.action = action;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
exports.TextMessage = TextMessage;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { IChatResponse } from '../../types/response';
|
|
2
|
-
import { IActionWithState } from '../../types/actionWithState';
|
|
3
|
-
import { IActionState } from '../../types/actionState';
|
|
4
|
-
export declare class UnpinResponse implements IChatResponse {
|
|
5
|
-
kind: "unpin";
|
|
6
|
-
messageId: number;
|
|
7
|
-
chatId: number;
|
|
8
|
-
traceId: number | string;
|
|
9
|
-
action: IActionWithState<IActionState>;
|
|
10
|
-
constructor(messageId: number, chatId: number, traceId: number | string, action: IActionWithState<IActionState>);
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=unpin.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"unpin.d.ts","sourceRoot":"","sources":["../../../entities/responses/unpin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,qBAAa,aAAc,YAAW,aAAa;IAC/C,IAAI,UAA0B;IAE9B,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC;gBAGnC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,GAAG,MAAM,EACxB,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC;CAO7C"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UnpinResponse = void 0;
|
|
4
|
-
const response_1 = require("../../types/response");
|
|
5
|
-
class UnpinResponse {
|
|
6
|
-
constructor(messageId, chatId, traceId, action) {
|
|
7
|
-
this.kind = response_1.BotResponseTypes.unpin;
|
|
8
|
-
this.messageId = messageId;
|
|
9
|
-
this.chatId = chatId;
|
|
10
|
-
this.traceId = traceId;
|
|
11
|
-
this.action = action;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
exports.UnpinResponse = UnpinResponse;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { InputFile } from 'telegraf/types';
|
|
2
|
-
import { IReplyMessage } from '../../types/response';
|
|
3
|
-
import { MessageSendingOptions } from '../../types/messageSendingOptions';
|
|
4
|
-
import { IActionWithState } from '../../types/actionWithState';
|
|
5
|
-
import { IActionState } from '../../types/actionState';
|
|
6
|
-
export declare class VideoMessage implements IReplyMessage<InputFile> {
|
|
7
|
-
kind: "video";
|
|
8
|
-
content: InputFile;
|
|
9
|
-
chatId: number;
|
|
10
|
-
replyId: number | undefined;
|
|
11
|
-
traceId: string | number;
|
|
12
|
-
disableWebPreview: boolean;
|
|
13
|
-
shouldPin: boolean;
|
|
14
|
-
action: IActionWithState<IActionState>;
|
|
15
|
-
constructor(video: InputFile, chatId: number, replyId: number | undefined, traceId: number | string, action: IActionWithState<IActionState>, options?: MessageSendingOptions);
|
|
16
|
-
}
|
|
17
|
-
//# sourceMappingURL=videoMessage.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"videoMessage.d.ts","sourceRoot":"","sources":["../../../entities/responses/videoMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAoB,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,qBAAa,YAAa,YAAW,aAAa,CAAC,SAAS,CAAC;IACzD,IAAI,UAA0B;IAE9B,OAAO,EAAE,SAAS,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,iBAAiB,UAAS;IAC1B,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC;gBAGnC,KAAK,EAAE,SAAS,EAChB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,OAAO,EAAE,MAAM,GAAG,MAAM,EACxB,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC,EACtC,OAAO,CAAC,EAAE,qBAAqB;CAStC"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.VideoMessage = void 0;
|
|
4
|
-
const response_1 = require("../../types/response");
|
|
5
|
-
class VideoMessage {
|
|
6
|
-
constructor(video, chatId, replyId, traceId, action, options) {
|
|
7
|
-
this.kind = response_1.BotResponseTypes.video;
|
|
8
|
-
this.disableWebPreview = false;
|
|
9
|
-
this.content = video;
|
|
10
|
-
this.chatId = chatId;
|
|
11
|
-
this.replyId = replyId;
|
|
12
|
-
this.traceId = traceId;
|
|
13
|
-
this.shouldPin = options?.pin ?? false;
|
|
14
|
-
this.action = action;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
exports.VideoMessage = VideoMessage;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"inverseRecord.d.ts","sourceRoot":"","sources":["../../helpers/inverseRecord.ts"],"names":[],"mappings":"AAAA,wBAAgB,aAAa,CAAC,CAAC,SAAS,WAAW,EAAE,CAAC,SAAS,WAAW,EACtE,KAAK,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAId,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CACpB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"reverseMap.d.ts","sourceRoot":"","sources":["../../helpers/reverseMap.ts"],"names":[],"mappings":"AAAA,wBAAgB,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAE1D"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"reverseRecord.d.ts","sourceRoot":"","sources":["../../helpers/reverseRecord.ts"],"names":[],"mappings":"AAAA,wBAAgB,aAAa,CAAC,CAAC,SAAS,WAAW,EAAE,CAAC,SAAS,WAAW,EACtE,KAAK,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAId,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CACpB"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
declare class JsonLogger {
|
|
2
|
-
private serializeError;
|
|
3
|
-
logObjectWithTraceId(botName: string, traceId: string | number, chatName: string, data: any): void;
|
|
4
|
-
logWithTraceId(botName: string, traceId: string | number, chatName: string, text: string): void;
|
|
5
|
-
errorWithTraceId<TData>(botName: string, traceId: string | number, chatName: string, errorObj: unknown, extraData?: TData | undefined): void;
|
|
6
|
-
}
|
|
7
|
-
export declare const Logger: JsonLogger;
|
|
8
|
-
export {};
|
|
9
|
-
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../services/logger.ts"],"names":[],"mappings":"AAAA,cAAM,UAAU;IAEZ,OAAO,CAAC,cAAc;IAQtB,oBAAoB,CAChB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,GAAG,MAAM,EACxB,QAAQ,EAAE,MAAM,EAEhB,IAAI,EAAE,GAAG;IAQb,cAAc,CACV,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,GAAG,MAAM,EACxB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM;IAOhB,gBAAgB,CAAC,KAAK,EAClB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,GAAG,MAAM,EACxB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,OAAO,EACjB,SAAS,CAAC,EAAE,KAAK,GAAG,SAAS;CAQpC;AAED,eAAO,MAAM,MAAM,YAAmB,CAAC"}
|
package/dist/services/logger.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Logger = void 0;
|
|
4
|
-
class JsonLogger {
|
|
5
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6
|
-
serializeError(error) {
|
|
7
|
-
const plainObject = {};
|
|
8
|
-
Object.getOwnPropertyNames(error).forEach(function (key) {
|
|
9
|
-
plainObject[key] = error[key];
|
|
10
|
-
});
|
|
11
|
-
return JSON.stringify(plainObject);
|
|
12
|
-
}
|
|
13
|
-
logObjectWithTraceId(botName, traceId, chatName,
|
|
14
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15
|
-
data) {
|
|
16
|
-
data.botName = botName;
|
|
17
|
-
data.traceId = traceId;
|
|
18
|
-
data.chatName = chatName;
|
|
19
|
-
console.log(data);
|
|
20
|
-
}
|
|
21
|
-
logWithTraceId(botName, traceId, chatName, text) {
|
|
22
|
-
console.log(`{"botName":"${botName}","traceId":"${traceId}","chatName":"${chatName}","text":"${text}"}`);
|
|
23
|
-
}
|
|
24
|
-
errorWithTraceId(botName, traceId, chatName, errorObj, extraData) {
|
|
25
|
-
console.error(`{"botName":"${botName}","traceId":"${traceId}","chatName":"${chatName}","error":${this.serializeError(errorObj)}${extraData ? `,"extraData":${JSON.stringify(extraData)}` : ''}}`);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
exports.Logger = new JsonLogger();
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { TaskRecord } from '../entities/taskRecord';
|
|
2
|
-
import { Milliseconds } from '../types/timeValues';
|
|
3
|
-
declare class TaskScheduler {
|
|
4
|
-
readonly activeTasks: TaskRecord[];
|
|
5
|
-
stopAll(): void;
|
|
6
|
-
createTask(name: string, action: () => void, interval: Milliseconds, executeRightAway: boolean, ownerName: string): void;
|
|
7
|
-
createOnetimeTask(name: string, action: () => void, delay: Milliseconds, ownerName: string): void;
|
|
8
|
-
}
|
|
9
|
-
export declare const Scheduler: TaskScheduler;
|
|
10
|
-
export {};
|
|
11
|
-
//# sourceMappingURL=taskScheduler.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"taskScheduler.d.ts","sourceRoot":"","sources":["../../services/taskScheduler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGnD,cAAM,aAAa;IACf,QAAQ,CAAC,WAAW,EAAE,UAAU,EAAE,CAAM;IAExC,OAAO;IAMP,UAAU,CACN,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,IAAI,EAClB,QAAQ,EAAE,YAAY,EACtB,gBAAgB,EAAE,OAAO,EACzB,SAAS,EAAE,MAAM;IAmBrB,iBAAiB,CACb,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,IAAI,EAClB,KAAK,EAAE,YAAY,EACnB,SAAS,EAAE,MAAM;CAoBxB;AAED,eAAO,MAAM,SAAS,eAAsB,CAAC"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Scheduler = void 0;
|
|
4
|
-
const taskRecord_1 = require("../entities/taskRecord");
|
|
5
|
-
const logger_1 = require("./logger");
|
|
6
|
-
class TaskScheduler {
|
|
7
|
-
constructor() {
|
|
8
|
-
this.activeTasks = [];
|
|
9
|
-
}
|
|
10
|
-
stopAll() {
|
|
11
|
-
this.activeTasks.forEach((task) => {
|
|
12
|
-
clearInterval(task.taskId);
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
createTask(name, action, interval, executeRightAway, ownerName) {
|
|
16
|
-
const taskId = setInterval(action, interval);
|
|
17
|
-
const task = new taskRecord_1.TaskRecord(name, taskId, interval);
|
|
18
|
-
if (executeRightAway) {
|
|
19
|
-
setImmediate(action);
|
|
20
|
-
}
|
|
21
|
-
logger_1.Logger.logWithTraceId(ownerName, `System:TaskScheduler-${ownerName}-${name}`, 'System', `Created task [${taskId}]${name}, that will run every ${interval}ms.`);
|
|
22
|
-
this.activeTasks.push(task);
|
|
23
|
-
}
|
|
24
|
-
createOnetimeTask(name, action, delay, ownerName) {
|
|
25
|
-
const actionWrapper = () => {
|
|
26
|
-
logger_1.Logger.logWithTraceId(ownerName, `System:TaskScheduler-${ownerName}-${name}`, 'System', `Executing delayed oneshot [${taskId}]${name}`);
|
|
27
|
-
action();
|
|
28
|
-
};
|
|
29
|
-
const taskId = setTimeout(actionWrapper, delay);
|
|
30
|
-
logger_1.Logger.logWithTraceId(ownerName, `System:TaskScheduler-${ownerName}-${name}`, 'System', `Created oneshot task [${taskId}]${name}, that will run in ${delay}ms.`);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
exports.Scheduler = new TaskScheduler();
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"daysOfTheWeek.d.ts","sourceRoot":"","sources":["../../types/daysOfTheWeek.ts"],"names":[],"mappings":"AAAA,oBAAY,GAAG;IACX,MAAM,IAAI;IACV,MAAM,IAAI;IACV,OAAO,IAAI;IACX,SAAS,IAAI;IACb,QAAQ,IAAI;IACZ,MAAM,IAAI;IACV,QAAQ,IAAI;CACf"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Day = void 0;
|
|
4
|
-
var Day;
|
|
5
|
-
(function (Day) {
|
|
6
|
-
Day[Day["Sunday"] = 0] = "Sunday";
|
|
7
|
-
Day[Day["Monday"] = 1] = "Monday";
|
|
8
|
-
Day[Day["Tuesday"] = 2] = "Tuesday";
|
|
9
|
-
Day[Day["Wednesday"] = 3] = "Wednesday";
|
|
10
|
-
Day[Day["Thursday"] = 4] = "Thursday";
|
|
11
|
-
Day[Day["Friday"] = 5] = "Friday";
|
|
12
|
-
Day[Day["Saturday"] = 6] = "Saturday";
|
|
13
|
-
})(Day || (exports.Day = Day = {}));
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"replyMessage.d.ts","sourceRoot":"","sources":["../../types/replyMessage.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa,CAAC,KAAK;IAChC,OAAO,EAAE,KAAK,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,iBAAiB,EAAE,OAAO,CAAC;CAC9B"}
|