raindar
This commit is contained in:
parent
0f9abdd0e1
commit
d0df64b48f
|
@ -1,5 +1,6 @@
|
|||
{
|
||||
"room": "",
|
||||
"token": ""
|
||||
"history": "",
|
||||
"token": "",
|
||||
"timezone": "",
|
||||
}
|
||||
|
|
17
src/index.js
17
src/index.js
|
@ -60,6 +60,8 @@ const curr_image_path = path.resolve("data", "current_radar.gif");
|
|||
client.on('ready', () => {
|
||||
(async () => {
|
||||
const channel = client.channels.cache.get(config.room);
|
||||
const webhooks = await channel.fetchWebhooks();
|
||||
const webhook = webhooks.first();
|
||||
|
||||
let radar_image = await get_rain_image();
|
||||
let radar_caption = await get_radar_caption();
|
||||
|
@ -84,6 +86,13 @@ client.on('ready', () => {
|
|||
let message_id = message.id;
|
||||
console.log(`Sent ${message.id}: ${message.content}`);
|
||||
|
||||
await webhook.send({
|
||||
content: caption,
|
||||
files: [curr_image_path, "https://weather.bangkok.go.th/Images/Radar/radarh.jpg"],
|
||||
threadId: config.history,
|
||||
});
|
||||
console.log(`Sent message to history`)
|
||||
|
||||
setInterval(async () => {
|
||||
let curr_image_size = fs.statSync(curr_image_path).size;
|
||||
|
||||
|
@ -118,7 +127,13 @@ client.on('ready', () => {
|
|||
|
||||
console.log(`Sent ${message.id}: ${message.content}`);
|
||||
message_id = message.id;
|
||||
console.log(message_id);
|
||||
|
||||
await webhook.send({
|
||||
content: caption,
|
||||
files: [curr_image_path, "https://weather.bangkok.go.th/Images/Radar/radarh.jpg"],
|
||||
threadId: config.history,
|
||||
});
|
||||
console.log(`Sent message to history`)
|
||||
} else {
|
||||
console.log("No change in data, go on.");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue