-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.ts
More file actions
26 lines (21 loc) · 752 Bytes
/
main.ts
File metadata and controls
26 lines (21 loc) · 752 Bytes
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
import "$std/dotenv/load.ts";
import { getToday, isLibur } from "./date.ts";
import { getStory } from "./hn.ts";
import { sendText } from "./wa.ts";
import { getWeather } from "./weather.ts";
const greeting = "Mengingatkan rekan-rekan untuk melakukan presensi~";
const chatJid = Deno.env.get("CHAT_ID")!;
export function createMessage() {
const messages = [getToday(), greeting, getWeather(), getStory()];
return Promise.all(messages).then((s) => s.join("\n\n"));
}
async function main() {
if (await isLibur()) return;
const message = await createMessage();
console.log(message);
await sendText(chatJid, message);
}
if (import.meta.main) {
Deno.cron("clockin", "30 0 * * 2-6", main);
Deno.cron("clockout", "0 10 * * 2-6", main);
}