Skip to content

Commit

Permalink
Update bot.js
Browse files Browse the repository at this point in the history
  • Loading branch information
brunitob committed Nov 4, 2020
1 parent 4c68d59 commit eed6778
Showing 1 changed file with 55 additions and 3 deletions.
58 changes: 55 additions & 3 deletions bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,52 @@ const db = pgPromise()({
database: process.env.DB_DATABASE || "",
});

const bannedUsers = [
453075221612724226,
467199474347802634,
411345682281267200,
467200970540187652,
488160478615568384,
499091490643902484,
747073483909103717,
747073501827170385,
747073521108385923,
747073513910960158,
466208848970252296,
574209605010325505,
759755652246667304,
759756251616772126,
760469074475352104,
760469082465632286,
759757358624407553,
451912503853580288,
429797762389901315,
417310827272601601,
472267859574390784,
531988737383464970,
501250853986893824,
501216778412621844,
579902813111582720,
760476514919383061,
496892392671150085,
760476479066472489,
760476456341602344,
752614944708624394,
464598521459507209,
464679388315910145,
428770809734103041,
414939190174679052,
487810867207864320,
502071946523967498,
502081752873828387,
579907903486689301,
760476500125679617,
];

const isBanned = (user) => {
return bannedUsers.includes(user);
};

const logger = pino({
prettyPrint: {
colorize: true, // --colorize
Expand Down Expand Up @@ -268,7 +314,7 @@ const handleStepAnswer = async (message) => {
console.log(error);
});
// Set timer for event start
startEventTimer(state.event);
// startEventTimer(state.event);
clearSetup();
break;
}
Expand All @@ -282,7 +328,7 @@ const handlePrivateEventMessage = async (message) => {
// 1) check if pass is correct and return an event
const event = await queryHelper.getEventFromPass(db, message.content);

if (event) {
if (event && !isBanned(message.author.id)) {
const getCode = await queryHelper.checkCodeForEventUsername(
db,
event.id,
Expand All @@ -294,6 +340,12 @@ const handlePrivateEventMessage = async (message) => {
logger.info(
`[DM] OK for ${message.author.username}/${message.author.id}`
);
console.log(
"[DEBBUG] ",
JSON.stringify(message),
" CODE: ",
getCode.code
);

// replace placeholder in message
const newMsg = defaultResponseMessage.replace("{code}", getCode.code);
Expand Down Expand Up @@ -510,7 +562,7 @@ const loadPendingEvents = async () => {
logger.info(
`Active event: ${row.id} | ${row.start_date} - ${row.end_date}`
);
startEventTimer(row);
// startEventTimer(row);
});
} else {
logger.info("[PG] No pending events");
Expand Down

0 comments on commit eed6778

Please sign in to comment.