2023-12-07 01:28:39 +01:00
|
|
|
import { launchWeb } from './web.js';
|
|
|
|
import { EventEmitter } from 'events';
|
|
|
|
import { loadDatabase } from './utils/database.js';
|
|
|
|
import dotenv from 'dotenv';
|
|
|
|
dotenv.config();
|
2023-12-06 08:46:58 +01:00
|
|
|
|
2023-12-07 01:28:39 +01:00
|
|
|
loadDatabase();
|
2023-12-06 08:46:58 +01:00
|
|
|
|
|
|
|
const submitEvent = new EventEmitter();
|
2023-12-07 01:28:39 +01:00
|
|
|
await launchWeb(submitEvent);
|
2023-12-06 08:46:58 +01:00
|
|
|
|
2023-12-07 12:33:59 +01:00
|
|
|
submitEvent.on("contacts/call", async (call) => {
|
2023-12-06 08:46:58 +01:00
|
|
|
let vote;
|
2023-12-06 19:11:14 +01:00
|
|
|
if (call.vote) {
|
2023-12-06 08:46:58 +01:00
|
|
|
console.log(`${call.phone} va voter`);
|
|
|
|
vote = 1;
|
|
|
|
} else {
|
|
|
|
console.log(`${call.phone} ne va pas voter`);
|
|
|
|
vote = 0;
|
|
|
|
}
|
2023-12-06 19:11:14 +01:00
|
|
|
await global.database.contacts.update(
|
|
|
|
{ vote: vote, called: 1 },
|
|
|
|
{ where: { phone: call.phone } },
|
|
|
|
);
|
2023-12-06 08:46:58 +01:00
|
|
|
});
|
2023-12-07 12:33:59 +01:00
|
|
|
submitEvent.on("contacts/add", (request) => {
|
2023-12-06 08:46:58 +01:00
|
|
|
console.log(request);
|
|
|
|
});
|
|
|
|
|
2023-12-06 19:11:14 +01:00
|
|
|
global.events = {
|
|
|
|
submitEvent: submitEvent,
|
|
|
|
}
|