Skip to content

Commit

Permalink
✨ Switch to general election answer at 18:00 on election day
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristianJoe committed Sep 26, 2021
1 parent dcaa4c7 commit 4fafbe0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
10 changes: 8 additions & 2 deletions handler/actionLocation.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import moment from 'moment-timezone';

import { buttonPostback } from '../lib/facebook';
import { byCities, byZipCodes } from '../data/locationMappings';
import { handleCity as handleCityCorona } from './actionLocationCorona';
Expand Down Expand Up @@ -66,8 +68,12 @@ https://m.me/tagesschau`);
const chooseLocation = async (chat, location) => {
const messageText = 'Was interessiert dich?';

let buttonCandidatesText = 'Kandidatencheck';
if (moment() - moment('2021-09-26T18:00:00+02:00') > 0 ) {
buttonCandidatesText = 'Bundestagswahl';
}
const buttonCandidates = buttonPostback(
'Kandidatencheck',
buttonCandidatesText,
{
action: 'location_candidates',
ags: location.keyCity,
Expand All @@ -76,7 +82,7 @@ const chooseLocation = async (chat, location) => {
category: 'Feature',
event: 'Location',
label: 'Choose',
subType: 'Kandidatencheck',
subType: buttonCandidatesText,
},
});

Expand Down
9 changes: 8 additions & 1 deletion handler/actionLocationCandidates.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
import { buttonPostback } from '../lib/facebook';
import moment from 'moment-timezone';

import { buttonPostback } from '../lib/facebook';
import { payloadFaq } from './payloadFaq';

import wahlkreisById from '../data/wahlkreisById';
import wahlkreiseByCity from '../data/wahlkreiseByCity';
import wahlkreiseByZip from '../data/wahlkreiseByZip';


export const handleCity = async (chat, location) => {
if (moment() - moment('2021-09-26T18:00:00+02:00') > 0 ) {
const payload = { action: 'faq', slug: 'election' };
return payloadFaq(chat, payload);
}

let wahlkreisIds;

if (location.zipCode) {
Expand Down

0 comments on commit 4fafbe0

Please sign in to comment.