signal-sdk 0.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/LICENSE +21 -0
- package/README.md +455 -0
- package/dist/SignalBot.d.ts +108 -0
- package/dist/SignalBot.js +811 -0
- package/dist/SignalCli.d.ts +135 -0
- package/dist/SignalCli.js +671 -0
- package/dist/__tests__/SignalBot.test.d.ts +1 -0
- package/dist/__tests__/SignalBot.test.js +102 -0
- package/dist/__tests__/SignalCli.test.d.ts +1 -0
- package/dist/__tests__/SignalCli.test.js +235 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +22 -0
- package/dist/interfaces.d.ts +937 -0
- package/dist/interfaces.js +11 -0
- package/package.json +67 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Signal SDK
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,455 @@
|
|
|
1
|
+
# Signal CLI SDK - TypeScript Wrapper for Signal CLI
|
|
2
|
+
|
|
3
|
+
A comprehensive TypeScript SDK for interacting with [signal-cli](https://github.com/AsamK/signal-cli), providing JSON-RPC communication and a powerful bot framework.
|
|
4
|
+
|
|
5
|
+
[](https://badge.fury.io/js/signal-sdk)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
[](https://github.com/AsamK/signal-cli)
|
|
8
|
+
[](https://www.typescriptlang.org/)
|
|
9
|
+
[](https://nodejs.org/)
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
### Core Capabilities
|
|
14
|
+
|
|
15
|
+
- **JSON-RPC Communication** - Direct communication with signal-cli daemon via JSON-RPC
|
|
16
|
+
- **TypeScript Support** - Complete type definitions with full IntelliSense support
|
|
17
|
+
- **Message Management** - Send, receive, and manage Signal messages
|
|
18
|
+
- **Real-time Events** - Listen to incoming messages and notifications
|
|
19
|
+
- **Production Ready** - Robust error handling and connection management
|
|
20
|
+
|
|
21
|
+
### SignalBot Framework
|
|
22
|
+
|
|
23
|
+
- **Simple Bot Creation** - Create powerful bots with minimal setup
|
|
24
|
+
- **Command System** - Built-in command parsing and routing
|
|
25
|
+
- **Event Handling** - React to messages, group events, and user actions
|
|
26
|
+
- **Admin Controls** - Role-based permissions and access control
|
|
27
|
+
- **Group Management** - Automated group creation and member management
|
|
28
|
+
- **Extensible** - Plugin-style architecture for custom functionality
|
|
29
|
+
|
|
30
|
+
### Advanced Features
|
|
31
|
+
|
|
32
|
+
- **File Attachments** - Send and receive files, images, and media
|
|
33
|
+
- **Group Operations** - Create, manage, and configure groups
|
|
34
|
+
- **Contact Management** - Add, update, remove, and manage contacts
|
|
35
|
+
- **Message Reactions** - React to messages with emoji reactions
|
|
36
|
+
- **Typing Indicators** - Send and receive typing notifications
|
|
37
|
+
- **Read Receipts** - Track message delivery and read status
|
|
38
|
+
- **Profile Management** - Update profile information and avatars
|
|
39
|
+
- **Payment Notifications** - Send payment receipts and notifications
|
|
40
|
+
- **Custom Sticker Packs** - Upload and manage custom sticker packs
|
|
41
|
+
- **User Status Checking** - Verify Signal registration status
|
|
42
|
+
- **Rate Limit Recovery** - Handle and recover from rate limiting
|
|
43
|
+
- **Phone Number Changes** - Change registered phone numbers
|
|
44
|
+
- **Progress Tracking** - Monitor upload progress for large files
|
|
45
|
+
|
|
46
|
+
## Quick Start
|
|
47
|
+
|
|
48
|
+
### Installation
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
npm install
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Prerequisites
|
|
55
|
+
|
|
56
|
+
1. **Node.js** (version 16 or later)
|
|
57
|
+
2. **Java Runtime Environment** (required by signal-cli)
|
|
58
|
+
3. **signal-cli** - Download and setup instructions available in [installation guide](./docs/installation.md)
|
|
59
|
+
|
|
60
|
+
[Detailed installation guide](./docs/installation.md)
|
|
61
|
+
|
|
62
|
+
### Basic Usage
|
|
63
|
+
|
|
64
|
+
```javascript
|
|
65
|
+
const { SignalCli } = require("signal-sdk");
|
|
66
|
+
|
|
67
|
+
// Initialize SignalCli with phone number
|
|
68
|
+
const signal = new SignalCli(undefined, "+1234567890");
|
|
69
|
+
|
|
70
|
+
// Connect to signal-cli daemon
|
|
71
|
+
await signal.connect();
|
|
72
|
+
|
|
73
|
+
// Send a message
|
|
74
|
+
await signal.sendMessage("+0987654321", "Hello from Signal CLI SDK!");
|
|
75
|
+
|
|
76
|
+
// Listen for incoming messages
|
|
77
|
+
signal.on("message", (message) => {
|
|
78
|
+
console.log("Received message:", message.envelope.dataMessage.message);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
// Graceful shutdown
|
|
82
|
+
await signal.gracefulShutdown();
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Create a Bot
|
|
86
|
+
|
|
87
|
+
```javascript
|
|
88
|
+
const { SignalBot } = require("signal-sdk");
|
|
89
|
+
|
|
90
|
+
// Initialize bot with configuration
|
|
91
|
+
const bot = new SignalBot({
|
|
92
|
+
phoneNumber: "+1234567890",
|
|
93
|
+
admins: ["+0987654321"],
|
|
94
|
+
group: {
|
|
95
|
+
name: "My Bot Group",
|
|
96
|
+
description: "A group managed by my bot",
|
|
97
|
+
createIfNotExists: true,
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
// Add custom commands
|
|
102
|
+
bot.addCommand({
|
|
103
|
+
name: "hello",
|
|
104
|
+
description: "Greet the user",
|
|
105
|
+
handler: async (message, args) => {
|
|
106
|
+
const name = args.join(" ") || "friend";
|
|
107
|
+
return `Hello ${name}! How can I help you today?`;
|
|
108
|
+
},
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
// Handle events
|
|
112
|
+
bot.on("ready", () => {
|
|
113
|
+
console.log("Bot is ready and listening for messages!");
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
bot.on("message", (message) => {
|
|
117
|
+
console.log(`Received: ${message.text} from ${message.sender}`);
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
// Start the bot
|
|
121
|
+
await bot.start();
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Your bot will automatically:
|
|
125
|
+
|
|
126
|
+
- Handle command parsing (default prefix: `/`)
|
|
127
|
+
- Provide built-in commands (`/help`, `/ping`)
|
|
128
|
+
- Manage group creation and membership
|
|
129
|
+
- Enforce admin permissions
|
|
130
|
+
- Handle errors gracefully
|
|
131
|
+
|
|
132
|
+
## Documentation
|
|
133
|
+
|
|
134
|
+
### Getting Started
|
|
135
|
+
|
|
136
|
+
- [Installation & Setup](./docs/installation.md)
|
|
137
|
+
- [Getting Started Guide](./docs/getting-started.md)
|
|
138
|
+
- [Device Linking](./docs/device-linking.md)
|
|
139
|
+
|
|
140
|
+
### API Reference
|
|
141
|
+
|
|
142
|
+
- [SignalCli Class](./docs/api-reference.md#signalcli)
|
|
143
|
+
- [SignalBot Class](./docs/api-reference.md#signalbot)
|
|
144
|
+
- [TypeScript Interfaces](./docs/api-reference.md#interfaces)
|
|
145
|
+
|
|
146
|
+
### Examples
|
|
147
|
+
|
|
148
|
+
- [Device Linking](./examples/sdk/00-device-linking.js) - Link your device to Signal
|
|
149
|
+
- [Basic SDK Usage](./examples/sdk/01-basic-usage.js) - Simple message sending
|
|
150
|
+
- [Quick Start](./examples/sdk/02-quick-start.js) - Complete getting started example
|
|
151
|
+
- [Group Management](./examples/sdk/03-group-management.js) - Create and manage groups
|
|
152
|
+
- [Contact Management](./examples/sdk/04-contact-management.js) - Handle contacts
|
|
153
|
+
- [File Handling](./examples/sdk/05-file-handling.js) - Send and receive files
|
|
154
|
+
- [Minimal Bot](./examples/bot/01-minimal-bot.js) - Simple bot implementation
|
|
155
|
+
- [Advanced Bot](./examples/bot/02-advanced-bot.js) - Full-featured bot example
|
|
156
|
+
|
|
157
|
+
### Advanced Topics
|
|
158
|
+
|
|
159
|
+
- [Advanced Features](./docs/advanced-features.md)
|
|
160
|
+
- [SignalBot Framework](./docs/signalbot-framework.md)
|
|
161
|
+
- [Feature Coverage Analysis](./FEATURE_COVERAGE.md)
|
|
162
|
+
- [Implementation Plan](./IMPLEMENTATION_PLAN.md)
|
|
163
|
+
- [FAQ](./docs/faq.md)
|
|
164
|
+
- [Troubleshooting](./docs/troubleshooting.md)
|
|
165
|
+
|
|
166
|
+
## Common Use Cases
|
|
167
|
+
|
|
168
|
+
### Send Messages
|
|
169
|
+
|
|
170
|
+
```javascript
|
|
171
|
+
const { SignalCli } = require("signal-sdk");
|
|
172
|
+
const signal = new SignalCli(undefined, "+1234567890");
|
|
173
|
+
|
|
174
|
+
await signal.connect();
|
|
175
|
+
await signal.sendMessage("+0987654321", "Hello World!");
|
|
176
|
+
await signal.gracefulShutdown();
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### Send Files
|
|
180
|
+
|
|
181
|
+
```javascript
|
|
182
|
+
// Send file with message
|
|
183
|
+
await signal.sendMessage("+0987654321", "Here's the document:", {
|
|
184
|
+
attachments: ["./path/to/document.pdf"],
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
// Send multiple files
|
|
188
|
+
await signal.sendMessage("+0987654321", "Photos from today:", {
|
|
189
|
+
attachments: ["./photo1.jpg", "./photo2.jpg"],
|
|
190
|
+
});
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### Group Management
|
|
194
|
+
|
|
195
|
+
```javascript
|
|
196
|
+
// Create a new group
|
|
197
|
+
const group = await signal.createGroup("My Group", [
|
|
198
|
+
"+0987654321",
|
|
199
|
+
"+1122334455",
|
|
200
|
+
]);
|
|
201
|
+
console.log("Group ID:", group.groupId);
|
|
202
|
+
|
|
203
|
+
// Send message to group
|
|
204
|
+
await signal.sendMessage(group.groupId, "Welcome to the group!");
|
|
205
|
+
|
|
206
|
+
// Update group info
|
|
207
|
+
await signal.updateGroup(group.groupId, {
|
|
208
|
+
title: "Updated Group Name",
|
|
209
|
+
description: "This is our group chat",
|
|
210
|
+
});
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
### Bot with Custom Commands
|
|
214
|
+
|
|
215
|
+
```javascript
|
|
216
|
+
const { SignalBot } = require("signal-sdk");
|
|
217
|
+
|
|
218
|
+
const bot = new SignalBot({
|
|
219
|
+
phoneNumber: "+1234567890",
|
|
220
|
+
admins: ["+0987654321"],
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
// Add weather command
|
|
224
|
+
bot.addCommand({
|
|
225
|
+
name: "weather",
|
|
226
|
+
description: "Get weather information",
|
|
227
|
+
handler: async (message, args) => {
|
|
228
|
+
const city = args.join(" ") || "New York";
|
|
229
|
+
// Integrate with weather API
|
|
230
|
+
return `Weather in ${city}: 22°C, sunny`;
|
|
231
|
+
},
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
// Add custom event handler
|
|
235
|
+
bot.on("groupMemberJoined", async (event) => {
|
|
236
|
+
await bot.sendMessage(event.groupId, `Welcome ${event.member.name}!`);
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
await bot.start();
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
## Testing
|
|
243
|
+
|
|
244
|
+
```bash
|
|
245
|
+
# Run all tests
|
|
246
|
+
npm test
|
|
247
|
+
|
|
248
|
+
# Run specific test suite
|
|
249
|
+
npm test -- --testNamePattern="SignalCli"
|
|
250
|
+
|
|
251
|
+
# Run with coverage
|
|
252
|
+
npm run test:coverage
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
## Development
|
|
256
|
+
|
|
257
|
+
```bash
|
|
258
|
+
# Clone the repository
|
|
259
|
+
git clone https://github.com/your-username/signal-cli-sdk.git
|
|
260
|
+
cd signal-cli-sdk
|
|
261
|
+
|
|
262
|
+
# Install dependencies
|
|
263
|
+
npm install
|
|
264
|
+
|
|
265
|
+
# Build the project
|
|
266
|
+
npm run build
|
|
267
|
+
|
|
268
|
+
# Run examples
|
|
269
|
+
npm run build && node examples/sdk/01-basic-usage.js
|
|
270
|
+
|
|
271
|
+
# Run tests
|
|
272
|
+
npm test
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
## Configuration
|
|
276
|
+
|
|
277
|
+
### Environment Variables
|
|
278
|
+
|
|
279
|
+
Create a `.env` file in your project root:
|
|
280
|
+
|
|
281
|
+
```env
|
|
282
|
+
SIGNAL_PHONE_NUMBER="+1234567890"
|
|
283
|
+
SIGNAL_ADMIN_NUMBER="+0987654321"
|
|
284
|
+
SIGNAL_RECIPIENT_NUMBER="+1122334455"
|
|
285
|
+
SIGNAL_GROUP_NAME="My Bot Group"
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
### SignalCli Configuration
|
|
289
|
+
|
|
290
|
+
```javascript
|
|
291
|
+
const { SignalCli } = require("signal-sdk");
|
|
292
|
+
|
|
293
|
+
// Basic configuration
|
|
294
|
+
const signal = new SignalCli(configPath, phoneNumber);
|
|
295
|
+
// configPath: Path to signal-cli config directory (optional)
|
|
296
|
+
// phoneNumber: Your registered Signal phone number (required)
|
|
297
|
+
|
|
298
|
+
// Example with custom config path
|
|
299
|
+
const signal = new SignalCli("/custom/signal-cli/config", "+1234567890");
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
### SignalBot Configuration
|
|
303
|
+
|
|
304
|
+
```javascript
|
|
305
|
+
const { SignalBot } = require("signal-sdk");
|
|
306
|
+
|
|
307
|
+
const bot = new SignalBot({
|
|
308
|
+
phoneNumber: "+1234567890", // Required: Your Signal phone number
|
|
309
|
+
admins: ["+0987654321"], // Required: Admin phone numbers
|
|
310
|
+
group: {
|
|
311
|
+
name: "My Bot Group", // Group name
|
|
312
|
+
description: "Managed by my bot", // Group description
|
|
313
|
+
createIfNotExists: true, // Create group if it doesn't exist
|
|
314
|
+
avatar: "./group-avatar.jpg", // Group avatar image
|
|
315
|
+
},
|
|
316
|
+
settings: {
|
|
317
|
+
commandPrefix: "/", // Command prefix (default: "/")
|
|
318
|
+
logMessages: true, // Log incoming messages (default: false)
|
|
319
|
+
welcomeNewMembers: true, // Welcome message for new members
|
|
320
|
+
cooldownSeconds: 2, // Command cooldown in seconds
|
|
321
|
+
},
|
|
322
|
+
});
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
## Troubleshooting
|
|
326
|
+
|
|
327
|
+
### Common Issues
|
|
328
|
+
|
|
329
|
+
1. **signal-cli not found**
|
|
330
|
+
|
|
331
|
+
```bash
|
|
332
|
+
# Make sure signal-cli is installed and in your PATH
|
|
333
|
+
# Download from: https://github.com/AsamK/signal-cli/releases
|
|
334
|
+
signal-cli --version
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
2. **Java not installed**
|
|
338
|
+
|
|
339
|
+
```bash
|
|
340
|
+
# Install Java (required by signal-cli)
|
|
341
|
+
# Ubuntu/Debian
|
|
342
|
+
sudo apt update && sudo apt install default-jre
|
|
343
|
+
|
|
344
|
+
# macOS with Homebrew
|
|
345
|
+
brew install openjdk
|
|
346
|
+
|
|
347
|
+
# Windows: Download from Oracle or use package manager
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
3. **Phone number not registered**
|
|
351
|
+
|
|
352
|
+
```bash
|
|
353
|
+
# Register your phone number with Signal first
|
|
354
|
+
signal-cli -a +1234567890 register
|
|
355
|
+
signal-cli -a +1234567890 verify CODE_FROM_SMS
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
4. **Connection timeout**
|
|
359
|
+
|
|
360
|
+
```bash
|
|
361
|
+
# Test signal-cli directly
|
|
362
|
+
signal-cli -a +1234567890 send +0987654321 "Test message"
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
5. **Permission denied on config directory**
|
|
366
|
+
```bash
|
|
367
|
+
# Fix permissions on signal-cli config directory
|
|
368
|
+
chmod -R 755 ~/.local/share/signal-cli/
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
[Complete troubleshooting guide](./docs/troubleshooting.md)
|
|
372
|
+
|
|
373
|
+
## Contributing
|
|
374
|
+
|
|
375
|
+
We welcome contributions! Please see our [Contributing Guide](./CONTRIBUTING.md) for details.
|
|
376
|
+
|
|
377
|
+
1. Fork the repository
|
|
378
|
+
2. Create a feature branch
|
|
379
|
+
3. Make your changes
|
|
380
|
+
4. Add tests
|
|
381
|
+
5. Submit a pull request
|
|
382
|
+
|
|
383
|
+
## License
|
|
384
|
+
|
|
385
|
+
This project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details.
|
|
386
|
+
|
|
387
|
+
## Acknowledgments
|
|
388
|
+
|
|
389
|
+
- [signal-cli](https://github.com/AsamK/signal-cli) - The underlying Signal CLI client
|
|
390
|
+
- [Signal Protocol](https://signal.org/docs/) - The Signal messaging protocol
|
|
391
|
+
- The Signal community for their excellent work
|
|
392
|
+
|
|
393
|
+
## Support
|
|
394
|
+
|
|
395
|
+
- **Documentation**: [docs/](./docs/)
|
|
396
|
+
- **Examples**: [examples/](./examples/)
|
|
397
|
+
- **Issues**: Report bugs and request features
|
|
398
|
+
- **Contributing**: See [CONTRIBUTING.md](./CONTRIBUTING.md)
|
|
399
|
+
|
|
400
|
+
---
|
|
401
|
+
|
|
402
|
+
**Built with TypeScript for the Signal community**
|
|
403
|
+
|
|
404
|
+
---
|
|
405
|
+
|
|
406
|
+
## Development Status
|
|
407
|
+
|
|
408
|
+
### Current Coverage: 39/39 signal-cli commands (100%) ✅
|
|
409
|
+
|
|
410
|
+
The SDK now provides **complete feature parity** with signal-cli, implementing all available commands and functionality.
|
|
411
|
+
|
|
412
|
+
**Latest Updates:**
|
|
413
|
+
|
|
414
|
+
- ✅ **Contact Management**: Complete removal with options (hide/forget)
|
|
415
|
+
- ✅ **User Status**: Check Signal registration status
|
|
416
|
+
- ✅ **Payment Notifications**: Send payment receipts and notes
|
|
417
|
+
- ✅ **Custom Stickers**: Upload and manage sticker packs
|
|
418
|
+
- ✅ **Rate Limit Recovery**: Handle rate limiting with captcha challenges
|
|
419
|
+
- ✅ **Phone Number Changes**: Change registered phone numbers
|
|
420
|
+
- ✅ **Enhanced Messaging**: Progress tracking for large file uploads
|
|
421
|
+
|
|
422
|
+
[**View Complete Feature Coverage Analysis →**](./FEATURE_COVERAGE.md)
|
|
423
|
+
[**View Implementation Details →**](./IMPLEMENTATION_PLAN.md)
|
|
424
|
+
|
|
425
|
+
---
|
|
426
|
+
|
|
427
|
+
## API Methods
|
|
428
|
+
|
|
429
|
+
Compatible with signal-cli v0.13.17 - **100% Feature Coverage**
|
|
430
|
+
|
|
431
|
+
| Category | Method | Description | Status |
|
|
432
|
+
| ------------- | -------------------------- | ---------------------------------- | ------ |
|
|
433
|
+
| **Messaging** | `send` | Send text messages and attachments | ✅ |
|
|
434
|
+
| | `sendReaction` | React to messages with emoji | ✅ |
|
|
435
|
+
| | `sendTyping` | Send typing indicators | ✅ |
|
|
436
|
+
| | `sendReceipt` | Send read receipts | ✅ |
|
|
437
|
+
| | `sendPaymentNotification` | Send payment notifications | ✅ |
|
|
438
|
+
| **Groups** | `createGroup` | Create new groups | ✅ |
|
|
439
|
+
| | `updateGroup` | Update group settings | ✅ |
|
|
440
|
+
| | `listGroups` | List all groups | ✅ |
|
|
441
|
+
| | `quitGroup` | Leave a group | ✅ |
|
|
442
|
+
| **Contacts** | `listContacts` | List all contacts | ✅ |
|
|
443
|
+
| | `updateContact` | Update contact information | ✅ |
|
|
444
|
+
| | `removeContact` | Remove contacts with options | ✅ |
|
|
445
|
+
| | `block` / `unblock` | Block/unblock contacts | ✅ |
|
|
446
|
+
| | `getUserStatus` | Check registration status | ✅ |
|
|
447
|
+
| **Stickers** | `listStickerPacks` | List sticker packs | ✅ |
|
|
448
|
+
| | `addStickerPack` | Install sticker packs | ✅ |
|
|
449
|
+
| | `uploadStickerPack` | Upload custom sticker packs | ✅ |
|
|
450
|
+
| **Advanced** | `submitRateLimitChallenge` | Handle rate limiting | ✅ |
|
|
451
|
+
| | `startChangeNumber` | Start phone number change | ✅ |
|
|
452
|
+
| | `finishChangeNumber` | Complete phone number change | ✅ |
|
|
453
|
+
| | `sendMessageWithProgress` | Enhanced messaging with progress | ✅ |
|
|
454
|
+
|
|
455
|
+
[Complete API documentation](./docs/api-reference.md)
|
|
@@ -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
|
+
}
|