-
Notifications
You must be signed in to change notification settings - Fork 8
/
telegram.js
38 lines (34 loc) · 1.21 KB
/
telegram.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
export async function sendHello(telegramBot, pipes){
// Send a connected message to telegram channels
for(var whatsappChat of Object.keys(pipes)){
sendTextMsg(
telegramBot,
`Channel successfully linked with Whatsapp Chat ${whatsappChat}`,
pipes[whatsappChat]
);
}
}
export async function sendRestart(telegramBot, pipes){
// Send a restart message after disconnect to telegram channels
for(var whatsappChat of Object.keys(pipes)){
sendTextMsg(
telegramBot,
`Connection re-established with Whatsapp Chat ${whatsappChat}`,
pipes[whatsappChat]
);
}
}
export async function sendAttachment(telegramBot, fileBuffer, channelName, name) {
await telegramBot.sendDocument(channelName, fileBuffer, {}, {'filename': name, });
}
export async function sendContact(telegramBot, contactData, telegramChannel){
await telegramBot.sendContact(
telegramChannel,
contactData.phoneNo,
contactData.firstName,
{lastName: contactData.lastName ?? ''}
);
}
export async function sendTextMsg(telegramBot, message, telegramChannel){
await telegramBot.sendMessage(telegramChannel, message);
}