Skip to content

Commit

Permalink
feat: Update app.js and dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
nestorzamili committed Dec 17, 2024
1 parent 500158d commit bdd1fff
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ logs/status.log
.env
whatsapp-bot-data/
.wwebjs_cache/
google-service-account.json
getSchedule.py
13 changes: 13 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const fs = require("fs");
const express = require("express");
const routes = require("./routes");
const getAIResponse = require("./utils/geminiClient");
const { exec } = require("child_process");

const app = express();
const { PORT = 3113 } = process.env;
Expand Down Expand Up @@ -72,6 +73,7 @@ client.on("message", async (message) => {
if (body.startsWith("!deleteMessage,"))
return handleDeleteMessage(message, body);
if (body.startsWith("!AI ")) return handleAIResponse(message, body, from);
if (body === "!jadwaldeo") return handleSchedule(message, from);
});

function log(message) {
Expand Down Expand Up @@ -135,3 +137,14 @@ async function handleAIResponse(message, body, from) {
log(`Error getting AI response: ${error}`);
}
}

async function handleSchedule(message, from) {
exec("python getSchedule.py", (error, stdout) => {
if (error) {
log(`Error getting schedule: ${error}`);
return;
}
message.reply(stdout);
log(`Sending schedule to ${from}`);
});
}
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"express": "^4.21.2",
"multer": "^1.4.5-lts.1",
"qrcode-terminal": "^0.12.0",
"whatsapp-web.js": "^1.26.1-alpha.2",
"whatsapp-web.js": "^1.26.1-alpha.3",
"wwebjs-aws-s3": "^1.0.2"
}
}

0 comments on commit bdd1fff

Please sign in to comment.