signal-sdk 0.0.8 → 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 +175 -59
- package/dist/SignalBot.d.ts +108 -0
- package/dist/SignalBot.js +811 -0
- package/dist/SignalCli.d.ts +205 -0
- package/dist/SignalCli.js +967 -0
- package/dist/__tests__/SignalBot.additional.test.d.ts +5 -0
- package/dist/__tests__/SignalBot.additional.test.js +333 -0
- package/dist/__tests__/SignalBot.test.d.ts +1 -0
- package/dist/__tests__/SignalBot.test.js +102 -0
- package/dist/__tests__/SignalCli.integration.test.d.ts +5 -0
- package/dist/__tests__/SignalCli.integration.test.js +218 -0
- package/dist/__tests__/SignalCli.methods.test.d.ts +5 -0
- package/dist/__tests__/SignalCli.methods.test.js +470 -0
- package/dist/__tests__/SignalCli.test.d.ts +1 -0
- package/dist/__tests__/SignalCli.test.js +479 -0
- package/dist/__tests__/config.test.d.ts +5 -0
- package/dist/__tests__/config.test.js +252 -0
- package/dist/__tests__/errors.test.d.ts +5 -0
- package/dist/__tests__/errors.test.js +276 -0
- package/dist/__tests__/retry.test.d.ts +4 -0
- package/dist/__tests__/retry.test.js +123 -0
- package/dist/__tests__/validators.test.d.ts +4 -0
- package/dist/__tests__/validators.test.js +147 -0
- package/dist/config.d.ts +67 -0
- package/dist/config.js +111 -0
- package/dist/errors.d.ts +32 -0
- package/dist/errors.js +75 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +26 -0
- package/dist/interfaces.d.ts +1073 -0
- package/dist/interfaces.js +11 -0
- package/dist/retry.d.ts +56 -0
- package/dist/retry.js +135 -0
- package/dist/validators.d.ts +59 -0
- package/dist/validators.js +170 -0
- package/package.json +5 -6
package/README.md
CHANGED
|
@@ -16,7 +16,9 @@
|
|
|
16
16
|
[](https://opensource.org/licenses/MIT)
|
|
17
17
|
[](https://github.com/AsamK/signal-cli)
|
|
18
18
|
[](https://www.typescriptlang.org/)
|
|
19
|
-
[](https://nodejs.org/)
|
|
20
|
+
[](./src/__tests__)
|
|
21
|
+
[](./src/__tests__)
|
|
20
22
|
[](https://liberapay.com/devbyben/donate)
|
|
21
23
|
|
|
22
24
|
</div>
|
|
@@ -25,11 +27,15 @@
|
|
|
25
27
|
|
|
26
28
|
### Core Capabilities
|
|
27
29
|
|
|
28
|
-
- **JSON-RPC Communication** - Direct communication with signal-cli daemon
|
|
29
|
-
- **TypeScript Support** - Complete type definitions with
|
|
30
|
+
- **JSON-RPC Communication** - Direct communication with signal-cli daemon
|
|
31
|
+
- **TypeScript Support** - Complete type definitions with IntelliSense
|
|
30
32
|
- **Message Management** - Send, receive, and manage Signal messages
|
|
31
|
-
- **Real-time Events** -
|
|
32
|
-
- **
|
|
33
|
+
- **Real-time Events** - Event-driven architecture for incoming messages
|
|
34
|
+
- **Enterprise-Grade** - Robust error handling and retry logic
|
|
35
|
+
- **Type-Safe Validation** - Comprehensive input validation
|
|
36
|
+
- **Retry Mechanism** - Exponential backoff with configurable policies
|
|
37
|
+
- **Structured Logging** - Multi-level logging system
|
|
38
|
+
- **Configuration Management** - Centralized configuration with validation
|
|
33
39
|
|
|
34
40
|
### SignalBot Framework
|
|
35
41
|
|
|
@@ -43,18 +49,23 @@
|
|
|
43
49
|
### Advanced Features
|
|
44
50
|
|
|
45
51
|
- **File Attachments** - Send and receive files, images, and media
|
|
46
|
-
- **Group Operations** - Create
|
|
47
|
-
- **Contact Management** -
|
|
48
|
-
- **Message Reactions** - React to messages with emoji
|
|
52
|
+
- **Group Operations** - Create and manage groups with detailed information
|
|
53
|
+
- **Contact Management** - Manage contacts with export/import capabilities
|
|
54
|
+
- **Message Reactions** - React to messages with emoji
|
|
49
55
|
- **Typing Indicators** - Send and receive typing notifications
|
|
50
56
|
- **Read Receipts** - Track message delivery and read status
|
|
51
57
|
- **Profile Management** - Update profile information and avatars
|
|
52
|
-
- **Payment Notifications** - Send payment
|
|
53
|
-
- **
|
|
54
|
-
- **User Status
|
|
55
|
-
- **Rate
|
|
58
|
+
- **Payment Notifications** - Send payment notifications
|
|
59
|
+
- **Sticker Packs** - Upload and manage custom sticker packs
|
|
60
|
+
- **User Status** - Verify Signal registration status
|
|
61
|
+
- **Rate Limiting** - Handle and recover from rate limits
|
|
56
62
|
- **Phone Number Changes** - Change registered phone numbers
|
|
57
|
-
- **Progress Tracking** - Monitor upload progress
|
|
63
|
+
- **Progress Tracking** - Monitor upload progress
|
|
64
|
+
- **Polls** - Create, vote, and terminate polls
|
|
65
|
+
- **Attachment Retrieval** - Retrieve attachments, avatars, and stickers
|
|
66
|
+
- **Account Management** - Update account settings
|
|
67
|
+
- **Stories** - View and interact with Signal stories
|
|
68
|
+
- **Group Information** - Retrieve detailed group permissions
|
|
58
69
|
|
|
59
70
|
## Quick Start
|
|
60
71
|
|
|
@@ -66,7 +77,7 @@ npm install signal-sdk
|
|
|
66
77
|
|
|
67
78
|
### Prerequisites
|
|
68
79
|
|
|
69
|
-
1. **Node.js** (version
|
|
80
|
+
1. **Node.js** (version 18 or later)
|
|
70
81
|
2. **Java Runtime Environment** (required by signal-cli)
|
|
71
82
|
|
|
72
83
|
**Note:** signal-cli binaries are included with the SDK - no separate installation required.
|
|
@@ -117,13 +128,13 @@ This command will:
|
|
|
117
128
|
const { SignalCli } = require("signal-sdk");
|
|
118
129
|
|
|
119
130
|
// Initialize SignalCli with phone number
|
|
120
|
-
const signal = new SignalCli("+
|
|
131
|
+
const signal = new SignalCli("+33111111111");
|
|
121
132
|
|
|
122
133
|
// Connect to signal-cli daemon
|
|
123
134
|
await signal.connect();
|
|
124
135
|
|
|
125
136
|
// Send a message
|
|
126
|
-
await signal.sendMessage("+
|
|
137
|
+
await signal.sendMessage("+33222222222", "Hello from Signal SDK!");
|
|
127
138
|
|
|
128
139
|
// Listen for incoming messages
|
|
129
140
|
signal.on("message", (message) => {
|
|
@@ -134,6 +145,35 @@ signal.on("message", (message) => {
|
|
|
134
145
|
await signal.gracefulShutdown();
|
|
135
146
|
```
|
|
136
147
|
|
|
148
|
+
### Advanced Configuration
|
|
149
|
+
|
|
150
|
+
```javascript
|
|
151
|
+
const { SignalCli, Logger } = require("signal-sdk");
|
|
152
|
+
|
|
153
|
+
// Configure with advanced settings
|
|
154
|
+
const config = {
|
|
155
|
+
retryConfig: {
|
|
156
|
+
maxAttempts: 3,
|
|
157
|
+
initialDelay: 1000,
|
|
158
|
+
maxDelay: 10000,
|
|
159
|
+
backoffMultiplier: 2,
|
|
160
|
+
},
|
|
161
|
+
rateLimiter: {
|
|
162
|
+
maxConcurrent: 5,
|
|
163
|
+
minInterval: 200,
|
|
164
|
+
},
|
|
165
|
+
logger: new Logger("info"),
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
const signal = new SignalCli("+33111111111", undefined, config);
|
|
169
|
+
|
|
170
|
+
await signal.connect();
|
|
171
|
+
|
|
172
|
+
// SDK automatically retries on failures, respects rate limits,
|
|
173
|
+
// validates inputs, and logs operations
|
|
174
|
+
await signal.sendMessage("+33222222222", "Reliable messaging!");
|
|
175
|
+
```
|
|
176
|
+
|
|
137
177
|
### Create a Bot
|
|
138
178
|
|
|
139
179
|
```javascript
|
|
@@ -141,8 +181,8 @@ const { SignalBot } = require("signal-sdk");
|
|
|
141
181
|
|
|
142
182
|
// Initialize bot with configuration
|
|
143
183
|
const bot = new SignalBot({
|
|
144
|
-
phoneNumber: "+
|
|
145
|
-
admins: ["+
|
|
184
|
+
phoneNumber: "+33111111111",
|
|
185
|
+
admins: ["+33222222222"],
|
|
146
186
|
group: {
|
|
147
187
|
name: "My Bot Group",
|
|
148
188
|
description: "A group managed by my bot",
|
|
@@ -221,10 +261,10 @@ Your bot will automatically:
|
|
|
221
261
|
|
|
222
262
|
```javascript
|
|
223
263
|
const { SignalCli } = require("signal-sdk");
|
|
224
|
-
const signal = new SignalCli("+
|
|
264
|
+
const signal = new SignalCli("+33111111111");
|
|
225
265
|
|
|
226
266
|
await signal.connect();
|
|
227
|
-
await signal.sendMessage("+
|
|
267
|
+
await signal.sendMessage("+33222222222", "Hello World!");
|
|
228
268
|
await signal.gracefulShutdown();
|
|
229
269
|
```
|
|
230
270
|
|
|
@@ -232,12 +272,12 @@ await signal.gracefulShutdown();
|
|
|
232
272
|
|
|
233
273
|
```javascript
|
|
234
274
|
// Send file with message
|
|
235
|
-
await signal.sendMessage("+
|
|
275
|
+
await signal.sendMessage("+33222222222", "Here's the document:", {
|
|
236
276
|
attachments: ["./path/to/document.pdf"],
|
|
237
277
|
});
|
|
238
278
|
|
|
239
279
|
// Send multiple files
|
|
240
|
-
await signal.sendMessage("+
|
|
280
|
+
await signal.sendMessage("+33222222222", "Photos from today:", {
|
|
241
281
|
attachments: ["./photo1.jpg", "./photo2.jpg"],
|
|
242
282
|
});
|
|
243
283
|
```
|
|
@@ -247,8 +287,8 @@ await signal.sendMessage("+0987654321", "Photos from today:", {
|
|
|
247
287
|
```javascript
|
|
248
288
|
// Create a new group
|
|
249
289
|
const group = await signal.createGroup("My Group", [
|
|
250
|
-
"+
|
|
251
|
-
"+
|
|
290
|
+
"+33222222222",
|
|
291
|
+
"+33333333333",
|
|
252
292
|
]);
|
|
253
293
|
console.log("Group ID:", group.groupId);
|
|
254
294
|
|
|
@@ -268,8 +308,8 @@ await signal.updateGroup(group.groupId, {
|
|
|
268
308
|
const { SignalBot } = require("signal-sdk");
|
|
269
309
|
|
|
270
310
|
const bot = new SignalBot({
|
|
271
|
-
phoneNumber: "+
|
|
272
|
-
admins: ["+
|
|
311
|
+
phoneNumber: "+33111111111",
|
|
312
|
+
admins: ["+33222222222"],
|
|
273
313
|
});
|
|
274
314
|
|
|
275
315
|
// Add weather command
|
|
@@ -291,8 +331,57 @@ bot.on("groupMemberJoined", async (event) => {
|
|
|
291
331
|
await bot.start();
|
|
292
332
|
```
|
|
293
333
|
|
|
334
|
+
## Quality & Reliability
|
|
335
|
+
|
|
336
|
+
### Code Quality
|
|
337
|
+
|
|
338
|
+
- **TypeScript Strict Mode** - Full type safety with strict compilation
|
|
339
|
+
- **Complete Type Coverage** - Type definitions for all APIs
|
|
340
|
+
- **Input Validation** - Comprehensive validation throughout
|
|
341
|
+
- **Error Handling** - Robust error classes and management
|
|
342
|
+
- **Retry Logic** - Exponential backoff with configurable policies
|
|
343
|
+
- **Configuration Management** - Validated configuration system
|
|
344
|
+
|
|
345
|
+
### Enterprise Features
|
|
346
|
+
|
|
347
|
+
- **Automatic Retries** - Configurable retry policies with exponential backoff
|
|
348
|
+
- **Rate Limiting** - Built-in rate limiter to prevent throttling
|
|
349
|
+
- **Structured Logging** - Multi-level logging system
|
|
350
|
+
- **Input Sanitization** - Automatic sanitization of inputs
|
|
351
|
+
- **E.164 Validation** - Strict international phone number validation
|
|
352
|
+
- **Connection Management** - Graceful connection handling
|
|
353
|
+
|
|
354
|
+
### Technical Specifications
|
|
355
|
+
|
|
356
|
+
- **Node.js**: >=18.0.0
|
|
357
|
+
- **TypeScript**: 5.8+ with strict mode
|
|
358
|
+
- **Test Coverage**: 225 passing tests across 9 suites
|
|
359
|
+
- **Code Coverage**: 57.52% overall, critical modules at 96-100%
|
|
360
|
+
- **signal-cli**: Compatible with v0.13.22
|
|
361
|
+
|
|
294
362
|
## Testing
|
|
295
363
|
|
|
364
|
+
The SDK has comprehensive test coverage to ensure reliability and quality.
|
|
365
|
+
|
|
366
|
+
### Test Statistics
|
|
367
|
+
|
|
368
|
+
- **Total Tests**: 225 passing
|
|
369
|
+
- **Test Suites**: 9 suites
|
|
370
|
+
- **Overall Coverage**: 57.52%
|
|
371
|
+
|
|
372
|
+
### Coverage by Module
|
|
373
|
+
|
|
374
|
+
| Module | Statements | Branches | Functions | Lines | Status |
|
|
375
|
+
|--------|-----------|----------|-----------|-------|--------|
|
|
376
|
+
| **validators.ts** | 100% | 100% | 100% | 100% | ✅ Perfect |
|
|
377
|
+
| **config.ts** | 100% | 97.22% | 100% | 100% | ✅ Excellent |
|
|
378
|
+
| **errors.ts** | 100% | 100% | 100% | 100% | ✅ Perfect |
|
|
379
|
+
| **retry.ts** | 96.15% | 85.71% | 100% | 97.95% | ✅ Excellent |
|
|
380
|
+
| **SignalCli.ts** | 68.68% | 55.46% | 65.9% | 72.7% | ✅ Good |
|
|
381
|
+
| **SignalBot.ts** | 24.33% | 16.94% | 29.68% | 24.59% | ⚠️ In Progress |
|
|
382
|
+
|
|
383
|
+
### Running Tests
|
|
384
|
+
|
|
296
385
|
```bash
|
|
297
386
|
# Run all tests
|
|
298
387
|
npm test
|
|
@@ -300,8 +389,25 @@ npm test
|
|
|
300
389
|
# Run specific test suite
|
|
301
390
|
npm test -- --testNamePattern="SignalCli"
|
|
302
391
|
|
|
303
|
-
# Run with coverage
|
|
392
|
+
# Run with coverage report
|
|
304
393
|
npm run test:coverage
|
|
394
|
+
|
|
395
|
+
# Run tests in watch mode
|
|
396
|
+
npm test -- --watch
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
### Test Suites
|
|
400
|
+
|
|
401
|
+
1. **validators.test.ts** - Input validation (100% coverage)
|
|
402
|
+
2. **config.test.ts** - Configuration management (100% coverage)
|
|
403
|
+
3. **errors.test.ts** - Error handling (100% coverage)
|
|
404
|
+
4. **retry.test.ts** - Retry logic (96% coverage)
|
|
405
|
+
5. **SignalCli.test.ts** - Core CLI functionality
|
|
406
|
+
6. **SignalCli.integration.test.ts** - Integration scenarios
|
|
407
|
+
7. **SignalCli.methods.test.ts** - API methods (31 tests)
|
|
408
|
+
8. **SignalBot.test.ts** - Bot framework
|
|
409
|
+
9. **SignalBot.additional.test.ts** - Extended bot features
|
|
410
|
+
|
|
305
411
|
```
|
|
306
412
|
|
|
307
413
|
## Development
|
|
@@ -331,9 +437,9 @@ npm test
|
|
|
331
437
|
Create a `.env` file in your project root:
|
|
332
438
|
|
|
333
439
|
```env
|
|
334
|
-
SIGNAL_PHONE_NUMBER="+
|
|
335
|
-
SIGNAL_ADMIN_NUMBER="+
|
|
336
|
-
SIGNAL_RECIPIENT_NUMBER="+
|
|
440
|
+
SIGNAL_PHONE_NUMBER="+33111111111"
|
|
441
|
+
SIGNAL_ADMIN_NUMBER="+33222222222"
|
|
442
|
+
SIGNAL_RECIPIENT_NUMBER="+33333333333"
|
|
337
443
|
SIGNAL_GROUP_NAME="My Bot Group"
|
|
338
444
|
```
|
|
339
445
|
|
|
@@ -348,7 +454,7 @@ const signal = new SignalCli(configPath, phoneNumber);
|
|
|
348
454
|
// phoneNumber: Your registered Signal phone number (required)
|
|
349
455
|
|
|
350
456
|
// Example with custom config path
|
|
351
|
-
const signal = new SignalCli("/custom/signal-cli/config", "+
|
|
457
|
+
const signal = new SignalCli("/custom/signal-cli/config", "+33111111111");
|
|
352
458
|
```
|
|
353
459
|
|
|
354
460
|
### SignalBot Configuration
|
|
@@ -357,8 +463,8 @@ const signal = new SignalCli("/custom/signal-cli/config", "+1234567890");
|
|
|
357
463
|
const { SignalBot } = require("signal-sdk");
|
|
358
464
|
|
|
359
465
|
const bot = new SignalBot({
|
|
360
|
-
phoneNumber: "+
|
|
361
|
-
admins: ["+
|
|
466
|
+
phoneNumber: "+33111111111", // Required: Your Signal phone number
|
|
467
|
+
admins: ["+33222222222"], // Required: Admin phone numbers
|
|
362
468
|
group: {
|
|
363
469
|
name: "My Bot Group", // Group name
|
|
364
470
|
description: "Managed by my bot", // Group description
|
|
@@ -403,15 +509,15 @@ const bot = new SignalBot({
|
|
|
403
509
|
|
|
404
510
|
```bash
|
|
405
511
|
# Register your phone number with Signal first
|
|
406
|
-
signal-cli -a +
|
|
407
|
-
signal-cli -a +
|
|
512
|
+
signal-cli -a +33111111111 register
|
|
513
|
+
signal-cli -a +33111111111 verify CODE_FROM_SMS
|
|
408
514
|
```
|
|
409
515
|
|
|
410
516
|
4. **Connection timeout**
|
|
411
517
|
|
|
412
518
|
```bash
|
|
413
519
|
# Test signal-cli directly
|
|
414
|
-
signal-cli -a +
|
|
520
|
+
signal-cli -a +33111111111 send +33222222222 "Test message"
|
|
415
521
|
```
|
|
416
522
|
|
|
417
523
|
5. **Permission denied on config directory**
|
|
@@ -459,29 +565,39 @@ This project is licensed under the MIT License - see the [LICENSE](./LICENSE) fi
|
|
|
459
565
|
|
|
460
566
|
Compatible with signal-cli v0.13.22 - **100% Feature Coverage**
|
|
461
567
|
|
|
462
|
-
| Category
|
|
463
|
-
|
|
|
464
|
-
| **Messaging**
|
|
465
|
-
|
|
|
466
|
-
|
|
|
467
|
-
|
|
|
468
|
-
|
|
|
469
|
-
|
|
|
470
|
-
|
|
|
471
|
-
|
|
|
472
|
-
|
|
|
473
|
-
|
|
|
474
|
-
|
|
|
475
|
-
|
|
|
476
|
-
|
|
|
477
|
-
|
|
|
478
|
-
|
|
|
479
|
-
|
|
|
480
|
-
|
|
|
481
|
-
|
|
|
482
|
-
|
|
|
483
|
-
|
|
|
484
|
-
|
|
|
568
|
+
| Category | Method | Description | Status |
|
|
569
|
+
| --------------- | -------------------------- | ---------------------------------- | ------ |
|
|
570
|
+
| **Messaging** | `send` | Send text messages and attachments | ✅ |
|
|
571
|
+
| | `sendReaction` | React to messages with emoji | ✅ |
|
|
572
|
+
| | `sendTyping` | Send typing indicators | ✅ |
|
|
573
|
+
| | `sendReceipt` | Send read receipts | ✅ |
|
|
574
|
+
| | `sendPaymentNotification` | Send payment notifications | ✅ |
|
|
575
|
+
| | `sendPollCreate` | Create polls in conversations | ✅ |
|
|
576
|
+
| | `sendPollVote` | Vote on existing polls | ✅ |
|
|
577
|
+
| | `sendPollTerminate` | Terminate a poll | ✅ |
|
|
578
|
+
| **Groups** | `createGroup` | Create new groups | ✅ |
|
|
579
|
+
| | `updateGroup` | Update group settings | ✅ |
|
|
580
|
+
| | `listGroups` | List all groups | ✅ |
|
|
581
|
+
| | `listGroupsDetailed` | List groups with detailed info | ✅ |
|
|
582
|
+
| | `quitGroup` | Leave a group | ✅ |
|
|
583
|
+
| **Contacts** | `listContacts` | List all contacts | ✅ |
|
|
584
|
+
| | `updateContact` | Update contact information | ✅ |
|
|
585
|
+
| | `removeContact` | Remove contacts with options | ✅ |
|
|
586
|
+
| | `sendContacts` | Export/send contact data | ✅ |
|
|
587
|
+
| | `block` / `unblock` | Block/unblock contacts | ✅ |
|
|
588
|
+
| | `getUserStatus` | Check registration status | ✅ |
|
|
589
|
+
| **Account** | `updateAccount` | Update account settings | ✅ |
|
|
590
|
+
| | `listAccountsDetailed` | List accounts with detailed info | ✅ |
|
|
591
|
+
| **Attachments** | `getAttachment` | Retrieve attachment by ID | ✅ |
|
|
592
|
+
| | `getAvatar` | Retrieve avatar by ID | ✅ |
|
|
593
|
+
| | `getSticker` | Retrieve sticker by ID | ✅ |
|
|
594
|
+
| **Stickers** | `listStickerPacks` | List sticker packs | ✅ |
|
|
595
|
+
| | `addStickerPack` | Install sticker packs | ✅ |
|
|
596
|
+
| | `uploadStickerPack` | Upload custom sticker packs | ✅ |
|
|
597
|
+
| **Advanced** | `submitRateLimitChallenge` | Handle rate limiting | ✅ |
|
|
598
|
+
| | `startChangeNumber` | Start phone number change | ✅ |
|
|
599
|
+
| | `finishChangeNumber` | Complete phone number change | ✅ |
|
|
600
|
+
| | `sendMessageWithProgress` | Enhanced messaging with progress | ✅ |
|
|
485
601
|
|
|
486
602
|
[Complete API documentation](./docs/api-reference.md)
|
|
487
603
|
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { EventEmitter } from 'events';
|
|
2
|
+
import { SignalCli } from './SignalCli';
|
|
3
|
+
import { BotConfig, BotCommand, BotStats } from './interfaces';
|
|
4
|
+
export declare class SignalBot extends EventEmitter {
|
|
5
|
+
private signalCli;
|
|
6
|
+
private config;
|
|
7
|
+
private commands;
|
|
8
|
+
private isRunning;
|
|
9
|
+
private botGroupId;
|
|
10
|
+
private stats;
|
|
11
|
+
private userCooldowns;
|
|
12
|
+
private actionQueue;
|
|
13
|
+
private isProcessingQueue;
|
|
14
|
+
private incomingMessageBuffer;
|
|
15
|
+
constructor(config: BotConfig, signalCliPath?: string);
|
|
16
|
+
/**
|
|
17
|
+
* Downloads an image from URL to a temporary file
|
|
18
|
+
* @param imageUrl URL of the image to download
|
|
19
|
+
* @returns Path to the temporary file
|
|
20
|
+
*/
|
|
21
|
+
private downloadImage;
|
|
22
|
+
/**
|
|
23
|
+
* Downloads an image from URL for commands (like NASA images)
|
|
24
|
+
* @param imageUrl URL of the image to download
|
|
25
|
+
* @param prefix Optional prefix for the temp file name
|
|
26
|
+
* @returns Path to the temporary file
|
|
27
|
+
*/
|
|
28
|
+
downloadImageFromUrl(imageUrl: string, prefix?: string): Promise<string>;
|
|
29
|
+
/**
|
|
30
|
+
* Sends a message with downloaded image attachment
|
|
31
|
+
* @param recipient Recipient to send to
|
|
32
|
+
* @param message Text message to send
|
|
33
|
+
* @param imageUrl URL of the image to download and send
|
|
34
|
+
* @param prefix Optional prefix for the temp file name
|
|
35
|
+
*/
|
|
36
|
+
sendMessageWithImage(recipient: string, message: string, imageUrl: string, prefix?: string): Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* Cleans up a temporary file
|
|
39
|
+
* @param filePath Path to the file to delete
|
|
40
|
+
*/
|
|
41
|
+
private cleanupTempFile;
|
|
42
|
+
/**
|
|
43
|
+
* Processes group avatar configuration
|
|
44
|
+
* @param avatar Avatar configuration (URL, file path, or base64)
|
|
45
|
+
* @returns Path to the avatar file or null if no avatar
|
|
46
|
+
*/
|
|
47
|
+
private processGroupAvatar;
|
|
48
|
+
/**
|
|
49
|
+
* Adds a custom command to the bot
|
|
50
|
+
*/
|
|
51
|
+
addCommand(command: BotCommand): void;
|
|
52
|
+
/**
|
|
53
|
+
* Removes a command from the bot
|
|
54
|
+
*/
|
|
55
|
+
removeCommand(name: string): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Gets all available commands
|
|
58
|
+
*/
|
|
59
|
+
getCommands(): BotCommand[];
|
|
60
|
+
/**
|
|
61
|
+
* Starts the bot
|
|
62
|
+
*/
|
|
63
|
+
start(): Promise<void>;
|
|
64
|
+
/**
|
|
65
|
+
* Stops the bot
|
|
66
|
+
*/
|
|
67
|
+
stop(): Promise<void>;
|
|
68
|
+
gracefulShutdown(): Promise<void>;
|
|
69
|
+
/**
|
|
70
|
+
* Sends a message
|
|
71
|
+
*/
|
|
72
|
+
sendMessage(recipient: string, message: string): Promise<void>;
|
|
73
|
+
/**
|
|
74
|
+
* Sends a reaction to a message
|
|
75
|
+
*/
|
|
76
|
+
sendReaction(recipient: string, targetAuthor: string, targetTimestamp: number, emoji: string): Promise<void>;
|
|
77
|
+
/**
|
|
78
|
+
* Sends a message with file attachments
|
|
79
|
+
*/
|
|
80
|
+
sendMessageWithAttachment(recipient: string, message: string, attachments: string[], cleanup?: string[]): Promise<void>;
|
|
81
|
+
/**
|
|
82
|
+
* Gets bot statistics
|
|
83
|
+
*/
|
|
84
|
+
getStats(): BotStats;
|
|
85
|
+
/**
|
|
86
|
+
* Checks if a user is an admin
|
|
87
|
+
*/
|
|
88
|
+
isAdmin(phoneNumber: string): boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Gets the bot group ID
|
|
91
|
+
*/
|
|
92
|
+
getBotGroupId(): string | null;
|
|
93
|
+
/**
|
|
94
|
+
* Gets the underlying SignalCli instance for advanced operations
|
|
95
|
+
*/
|
|
96
|
+
getSignalCli(): SignalCli;
|
|
97
|
+
private setupDefaultCommands;
|
|
98
|
+
private setupBotGroup;
|
|
99
|
+
private setupEventHandlers;
|
|
100
|
+
private handleMessage;
|
|
101
|
+
private handleCommand;
|
|
102
|
+
private sendCommandResponse;
|
|
103
|
+
private isOnCooldown;
|
|
104
|
+
private processActionQueue;
|
|
105
|
+
private sendWelcomeMessage;
|
|
106
|
+
private formatUptime;
|
|
107
|
+
private log;
|
|
108
|
+
}
|