Skip to content

Commit

Permalink
add send all option
Browse files Browse the repository at this point in the history
  • Loading branch information
itamarshubin committed Dec 15, 2024
1 parent 97a26a8 commit f1cd0ed
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
"license": "ISC",
"dependencies": {
"dotenv": "^16.3.1",
"firebase": "^9.23.0",
"firebase": "^11.1.0",
"qrcode-terminal": "^0.12.0",
"whatsapp-web.js": "github:pedroslopez/whatsapp-web.js#webpack-exodus"
"whatsapp-web.js": "^1.26.0"
},
"devDependencies": {
"@types/qrcode-terminal": "^0.12.0",
Expand Down
5 changes: 5 additions & 0 deletions src/constants/yeshiva-years.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,10 @@ export const ALL_YESHIVA_YEARS: string[] = [
"יג",
"יד",
"טו",
"טז",
"יז",
"יח",
"יט",
"כ",
"ללא שנה",
];
8 changes: 7 additions & 1 deletion src/firebase/shabbas-manage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,4 +360,10 @@ export const resumeShabbas = async (msg: Message) => {
client.sendMessage(msg.from, `הרישום ממשיך`);
};

const alertSubscribers = async (msg: Message) => {};
export const sendAll = async (msg: string) => {
const docs = await getDocs(query(collection(fireStore, "/users")));

docs.forEach((doc) => {
client.sendMessage(doc.data().phone, msg);
});
};
7 changes: 6 additions & 1 deletion src/message-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
getAlcoholics,
closeShabbas,
resumeShabbas,
sendAll,
} from "./firebase/shabbas-manage";
import { HELP_MESSAGE } from "./constants/help-message";
import { sendSpecialMessages } from "./constants/special-response";
Expand Down Expand Up @@ -114,12 +115,16 @@ export const messageHandler = async (msg: Message) => {
await closeShabbas(msg);
return;
}

if (msg.body.startsWith("!resume") && (await isAdmin(msg))) {
await resumeShabbas(msg);
return;
}

//Added the /all for the gamers there😁
if (msg.body.startsWith("/all") && (await isAdmin(msg))) {
sendAll(msg.body.split("/all")[1].trim());
}
switch (msg.body) {
case "כן":
await addUser(msg);
Expand Down

0 comments on commit f1cd0ed

Please sign in to comment.