signal-sdk 0.0.8 → 0.0.9

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.
@@ -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
+ }