-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpitch_date_question.js
33 lines (28 loc) · 1.04 KB
/
pitch_date_question.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/* @flow */
import type { Company, Message } from '../types';
import CompanyIntentInteraction from './company_intent';
import moment from 'moment';
export default class PitchDateQuestionInteraction
extends CompanyIntentInteraction {
helpText = 'shows when a company is pitching';
exampleText = "When is _Spyce_ pitching?";
abstract = false;
intents = ['pitch_date'];
responseFromCompany(company: Company, message: Message): ?string {
if (!company.pitch_on) {
return `<@${message.user}>: I don't see a scheduled pitch for ${company.name}.`;
}
const when = moment.unix(company.pitch_on);
if (moment().diff(when) > 0) {
return `<@${message.user}>: ${company.name} pitched ${company.team} ${when.fromNow()}.`;
} else {
return `<@${message.user}>: ${company.name} is coming in to ${company.team} ${when.calendar(null, {
sameDay: '[today]',
nextDay: '[tomorrow]',
lastDay: '[yesterday]',
lastWeek: '[last] dddd',
sameElse: "[on] dddd MMM Do [at] h:mm A",
})}!`;
}
}
}