-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreminders.js
90 lines (83 loc) · 2.46 KB
/
reminders.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
const schedule = require("node-schedule");
const { messageForWater, days, daysEn } = require("./constants");
class Reminder {
//abstract class
constructor(hour, minute, tz) {
if (this.constructor === Reminder) {
throw new Error("Cannot instantiate this class");
}
//works
this.hour = hour;
this.minute = minute;
this.tz = tz;
}
message;
mentions;
setReminderMessage() {
message = mentions + this.message;
}
setMentions(mentions) {
this.mentions = mentions;
}
}
Reminder.prototype.addReminderMessage = function () {};
Reminder.prototype.setReminder = function () {};
class WaterReminder extends Reminder {
constructor(hour, minute, tz, message) {
super(hour, minute, tz);
this.message = message;
console.log("asdasdasd", this.message);
}
//message = messageForWater;
mentions;
setReminder(theChannel) {
const rule = new schedule.RecurrenceRule();
rule.hour = this.hour;
rule.minute = this.minute;
rule.tz = this.tz;
const job = schedule.scheduleJob(rule, () => {
theChannel.send(this.message);
});
}
setMentions(mentions) {
this.mentions = mentions;
console.log("naisu");
}
setReminderMessage() {
this.message = this.mentions + "\n" + this.message;
//gia swsth seira einai etsi
}
}
class CourseReminder extends Reminder {
constructor(hour, minute, tz, course, teacher, link, dayOfWeek, end) {
super(hour, minute, tz);
this.course = course;
this.teacher = teacher;
this.link = link;
this.dayOfWeek = dayOfWeek;
this.end = end; //string for diplay purposes only
}
setReminder(theChannel) {
const rule = new schedule.RecurrenceRule();
rule.hour = this.hour;
rule.minute = this.minute;
rule.tz = this.tz;
rule.dayOfWeek = this.dayOfWeek;
const job = schedule.scheduleJob(rule, () => {
theChannel.send(this.message + "\n" + this.link);
});
}
setMentions(mentions) {
this.mentions = mentions;
}
setReminderMessage() {
//TODO LIGH DOYLITSA EDW
this.message = this.teacher + "\n" + this.course;
//gia swsth seira einai etsi
}
}
//TODO NA BALW NA KANEI THN ANANEWSH KATHE FORA POY GINETAI NEW KAI NA FTIAXNEI TO JOB
module.exports = {
WaterReminder,
CourseReminder,
};