publish
This commit is contained in:
parent
d0df64b48f
commit
4c4db68a03
15
src/index.js
15
src/index.js
|
@ -34,7 +34,8 @@ client.once(Events.ClientReady, readyClient => {
|
||||||
|
|
||||||
async function get_rain_image() {
|
async function get_rain_image() {
|
||||||
try {
|
try {
|
||||||
const radar_image = await axios.get('https://weather.bangkok.go.th/Images/Radar/radar.gif', {
|
let radar_src = "https://weather.bangkok.go.th/Images/Radar/radarh.jpg"
|
||||||
|
const radar_image = await axios.get(radar_src, {
|
||||||
responseType: "stream"
|
responseType: "stream"
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -55,7 +56,7 @@ async function get_radar_caption() {
|
||||||
return root.querySelector('#repeaDaily_lblDESCRIPTION_0').childNodes[0]._rawText;
|
return root.querySelector('#repeaDaily_lblDESCRIPTION_0').childNodes[0]._rawText;
|
||||||
}
|
}
|
||||||
|
|
||||||
const curr_image_path = path.resolve("data", "current_radar.gif");
|
const curr_image_path = path.resolve("data", "current_radar.jpg");
|
||||||
|
|
||||||
client.on('ready', () => {
|
client.on('ready', () => {
|
||||||
(async () => {
|
(async () => {
|
||||||
|
@ -76,11 +77,11 @@ client.on('ready', () => {
|
||||||
|
|
||||||
let date = new Date().toLocaleString('th-TH');
|
let date = new Date().toLocaleString('th-TH');
|
||||||
|
|
||||||
let caption = `# Raindar Update\n## ${date}\n${radar_caption}\n\nImages: GIF (left) - Static Image (right)`
|
let caption = `# Raindar Update\n## ${date}\n${radar_caption}\n\nLeft: Current Observation\nRight: 3 hour forecast`
|
||||||
|
|
||||||
let message = await channel.send({
|
let message = await channel.send({
|
||||||
content: caption,
|
content: caption,
|
||||||
files: [curr_image_path, "https://weather.bangkok.go.th/Images/Radar/radarh.jpg"]
|
files: [curr_image_path, "https://dds.bangkok.go.th/Radar/radar_rain.gif"]
|
||||||
});
|
});
|
||||||
|
|
||||||
let message_id = message.id;
|
let message_id = message.id;
|
||||||
|
@ -88,7 +89,7 @@ client.on('ready', () => {
|
||||||
|
|
||||||
await webhook.send({
|
await webhook.send({
|
||||||
content: caption,
|
content: caption,
|
||||||
files: [curr_image_path, "https://weather.bangkok.go.th/Images/Radar/radarh.jpg"],
|
files: [curr_image_path, "https://dds.bangkok.go.th/Radar/radar_rain.gif"],
|
||||||
threadId: config.history,
|
threadId: config.history,
|
||||||
});
|
});
|
||||||
console.log(`Sent message to history`)
|
console.log(`Sent message to history`)
|
||||||
|
@ -122,7 +123,7 @@ client.on('ready', () => {
|
||||||
|
|
||||||
let message = await channel.send({
|
let message = await channel.send({
|
||||||
content: caption,
|
content: caption,
|
||||||
files: [curr_image_path, "https://weather.bangkok.go.th/Images/Radar/radarh.jpg"]
|
files: [curr_image_path, "https://dds.bangkok.go.th/Radar/radar_rain.gif"]
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(`Sent ${message.id}: ${message.content}`);
|
console.log(`Sent ${message.id}: ${message.content}`);
|
||||||
|
@ -130,7 +131,7 @@ client.on('ready', () => {
|
||||||
|
|
||||||
await webhook.send({
|
await webhook.send({
|
||||||
content: caption,
|
content: caption,
|
||||||
files: [curr_image_path, "https://weather.bangkok.go.th/Images/Radar/radarh.jpg"],
|
files: [curr_image_path, "https://dds.bangkok.go.th/Radar/radar_rain.gif"],
|
||||||
threadId: config.history,
|
threadId: config.history,
|
||||||
});
|
});
|
||||||
console.log(`Sent message to history`)
|
console.log(`Sent message to history`)
|
||||||
|
|
Loading…
Reference in New Issue