Skip to content

Commit

Permalink
Invite via link if privacy issue
Browse files Browse the repository at this point in the history
Signed-off-by: Prince Mendiratta <prince.mendi@gmail.com>
  • Loading branch information
Prince-Mendiratta committed Nov 29, 2021
1 parent c1538ab commit 74c0c03
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
Binary file added images/BotsApp_invite.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 4 additions & 3 deletions lib/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ const data = {
"```The number entered is already a member of this group.```",
NOT_ON_WHATSAPP:
"```The number you're trying to add isn't available on WhatsApp.\nPlease verify the number again.```",
SUCCESS: " added successfully!"
SUCCESS: " added successfully!",
PRIVACY: "```The number you're trying to add cannot be added to the group directly. An invite link has been sent to them.```"
},
admins: {
DESCRIPTION: "Tag admins",
Expand Down Expand Up @@ -157,10 +158,10 @@ const data = {
rename: {
DESCRIPTION: "Module to rename a pdf or text document.",
EXTENDED_DESCRIPTION:
"```Use this module to rename documents by ```replying to them``` *.rename <new-name>*.",
"```Use this module to rename documents by replying to them``` *.rename <new-name>*.",
DOWNLOADING: "```Your document is being processed...```",
PROVIDE_NEW_NAME: "```Provide a new name for your document.```",
REPLY_TO_DOCUMENT: "```Reply to a valid document message to change it's file name.```",
REPLY_TO_DOCUMENT: "```Reply to a valid document message to change its file name.```",
ERROR: "```Woops, something went wrong. Try again later, or proabaly not with this again...```"

},
Expand Down
24 changes: 23 additions & 1 deletion modules/add.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const chalk = require("chalk");
const STRINGS = require("../lib/db.js");
const ADD = STRINGS.add;
const inputSanitization = require("../sidekick/input-sanitization");
const fs = require('fs');

module.exports = {
name: "add",
Expand Down Expand Up @@ -73,6 +74,27 @@ module.exports = {
MessageType.text
).catch(err => inputSanitization.handleError(err, client, BotsApp));
return;
} else if (response[number + "@c.us"] == 403) {
await client.sendMessage(
BotsApp.chatId,
ADD.PRIVACY,
MessageType.text
).catch(err => inputSanitization.handleError(err, client, BotsApp));
var tom = Math.round(new Date(new Date().getTime() + (24 * 60 * 60 * 1000)).getTime() / 1000);
var invite = {
caption: "```Hi! You have been invited to join this WhatsApp group by BotsApp!```\n\n🔗https://mybotsapp.com",
groupJid: BotsApp.chatId,
groupName: BotsApp.groupName,
inviteCode: "botsappinvite",
inviteExpiration: tom,
jpegThumbnail: fs.readFileSync('./images/BotsApp_invite.jpeg')
}
client.sendMessage(
number + "@s.whatsapp.net",
invite,
MessageType.groupInviteMessage
)
return;
} else if (response[number + "@c.us"] == 409) {
client.sendMessage(
BotsApp.chatId,
Expand All @@ -83,7 +105,7 @@ module.exports = {
}
client.sendMessage(
BotsApp.chatId,
"``` " + number + ADD.SUCCESS + "```",
"```" + number + ADD.SUCCESS + "```",
MessageType.text
);
} catch (err) {
Expand Down

0 comments on commit 74c0c03

Please sign in to comment.