Unverified Commit bf14f266 authored by Isabella Sko艡epov谩's avatar Isabella Sko艡epov谩
Browse files

Do not crash on error in bot 馃弮

parent 87eed40a
......@@ -8,6 +8,10 @@ async function readCredentials() {
return JSON.parse(await promisify(fs.readFile)('creds.json', 'utf-8'))
}
function timeout(ms) {
return new Promise(res => setTimeout(res, ms))
}
console.log('starting')
;(async () => {
const args = await Travian.generateArgs({
......@@ -22,8 +26,15 @@ console.log('starting')
while (true) {
delete require.cache[require.resolve('./travian')]
delete require.cache[require.resolve('./bot')]
try {
// eslint-disable-next-line global-require
await require('./bot').bot(require('./travian').travianImpl(...args))
} catch (e) {
console.error('Detected problem while running bot...')
console.error(e)
console.error("Sleeping for 5 seconds so that it doesn't use whole CPU")
await timeout(5000)
}
}
} catch (e) {
travian.close()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment