Remove image sending capabilities - cant be tested
This commit is contained in:
1362
bridge/package-lock.json
generated
Normal file
1362
bridge/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -12,13 +12,6 @@ interface SendCommand {
|
||||
text: string;
|
||||
}
|
||||
|
||||
interface SendImageCommand {
|
||||
type: 'send_image';
|
||||
to: string;
|
||||
imagePath: string;
|
||||
caption?: string;
|
||||
}
|
||||
|
||||
interface BridgeMessage {
|
||||
type: 'message' | 'status' | 'qr' | 'error';
|
||||
[key: string]: unknown;
|
||||
@@ -79,7 +72,7 @@ export class BridgeServer {
|
||||
|
||||
ws.on('message', async (data) => {
|
||||
try {
|
||||
const cmd = JSON.parse(data.toString()) as SendCommand | SendImageCommand;
|
||||
const cmd = JSON.parse(data.toString()) as SendCommand;
|
||||
await this.handleCommand(cmd);
|
||||
ws.send(JSON.stringify({ type: 'sent', to: cmd.to }));
|
||||
} catch (error) {
|
||||
@@ -99,11 +92,9 @@ export class BridgeServer {
|
||||
});
|
||||
}
|
||||
|
||||
private async handleCommand(cmd: SendCommand | SendImageCommand): Promise<void> {
|
||||
private async handleCommand(cmd: SendCommand): Promise<void> {
|
||||
if (cmd.type === 'send' && this.wa) {
|
||||
await this.wa.sendMessage(cmd.to, cmd.text);
|
||||
} else if (cmd.type === 'send_image' && this.wa) {
|
||||
await this.wa.sendImage(cmd.to, cmd.imagePath, cmd.caption);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ import makeWASocket, {
|
||||
import { Boom } from '@hapi/boom';
|
||||
import qrcode from 'qrcode-terminal';
|
||||
import pino from 'pino';
|
||||
import { writeFile, mkdir, readFile } from 'fs/promises';
|
||||
import { writeFile, mkdir } from 'fs/promises';
|
||||
import { join } from 'path';
|
||||
import { homedir } from 'os';
|
||||
import { randomBytes } from 'crypto';
|
||||
@@ -217,18 +217,6 @@ export class WhatsAppClient {
|
||||
await this.sock.sendMessage(to, { text });
|
||||
}
|
||||
|
||||
async sendImage(to: string, imagePath: string, caption?: string): Promise<void> {
|
||||
if (!this.sock) {
|
||||
throw new Error('Not connected');
|
||||
}
|
||||
|
||||
const buffer = await readFile(imagePath);
|
||||
await this.sock.sendMessage(to, {
|
||||
image: buffer,
|
||||
caption: caption || undefined,
|
||||
});
|
||||
}
|
||||
|
||||
async disconnect(): Promise<void> {
|
||||
if (this.sock) {
|
||||
this.sock.end(undefined);
|
||||
|
||||
@@ -83,20 +83,6 @@ class WhatsAppChannel(BaseChannel):
|
||||
return
|
||||
|
||||
try:
|
||||
# Send media files first
|
||||
for media_path in (msg.media or []):
|
||||
try:
|
||||
payload = {
|
||||
"type": "send_image",
|
||||
"to": msg.chat_id,
|
||||
"imagePath": media_path,
|
||||
}
|
||||
await self._ws.send(json.dumps(payload, ensure_ascii=False))
|
||||
except Exception as e:
|
||||
logger.error("Error sending WhatsApp media {}: {}", media_path, e)
|
||||
|
||||
# Send text message if there's content
|
||||
if msg.content:
|
||||
payload = {
|
||||
"type": "send",
|
||||
"to": msg.chat_id,
|
||||
|
||||
Reference in New Issue
Block a user