Skip to content

Instantly share code, notes, and snippets.

@chalkpe
Created April 27, 2018 01:24
Show Gist options
  • Select an option

  • Save chalkpe/5aafff198ca0eaf1c394aaa4d9f23709 to your computer and use it in GitHub Desktop.

Select an option

Save chalkpe/5aafff198ca0eaf1c394aaa4d9f23709 to your computer and use it in GitHub Desktop.
const axios = require('axios')
const chatId = ???
const token = '???'
const api = 'https://api.telegram.org'
const page = 'https://www.ubuntu.com/download/desktop'
const delay = t => new Promise((res, rej) => setTimeout(res, t))
async function wow () {
while (true) {
try {
const {data} = await axios.get(page)
if (data.includes('18.04')) break
console.log(new Date().toISOString(), 'not yet')
await delay(3000)
} catch (err) {
console.error(err)
}
}
console.log(new Date().toISOString(), 'wow! released!')
await axios.get(`${api}/bot${token}/sendMessage`, {
params: {
chat_id: chatId,
text: 'wow Ubuntu 18.04 is released! ' + page
}
})
}
wow()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment