raindar
This commit is contained in:
parent
0f9abdd0e1
commit
d0df64b48f
|
@ -1,5 +1,6 @@
|
||||||
{
|
{
|
||||||
"room": "",
|
"room": "",
|
||||||
"token": ""
|
"history": "",
|
||||||
|
"token": "",
|
||||||
"timezone": "",
|
"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', () => {
|
client.on('ready', () => {
|
||||||
(async () => {
|
(async () => {
|
||||||
const channel = client.channels.cache.get(config.room);
|
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_image = await get_rain_image();
|
||||||
let radar_caption = await get_radar_caption();
|
let radar_caption = await get_radar_caption();
|
||||||
|
@ -83,6 +85,13 @@ client.on('ready', () => {
|
||||||
|
|
||||||
let message_id = message.id;
|
let message_id = message.id;
|
||||||
console.log(`Sent ${message.id}: ${message.content}`);
|
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 () => {
|
setInterval(async () => {
|
||||||
let curr_image_size = fs.statSync(curr_image_path).size;
|
let curr_image_size = fs.statSync(curr_image_path).size;
|
||||||
|
@ -118,7 +127,13 @@ client.on('ready', () => {
|
||||||
|
|
||||||
console.log(`Sent ${message.id}: ${message.content}`);
|
console.log(`Sent ${message.id}: ${message.content}`);
|
||||||
message_id = message.id;
|
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 {
|
} else {
|
||||||
console.log("No change in data, go on.");
|
console.log("No change in data, go on.");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue