imageGenerator check

This commit is contained in:
ale 2021-01-28 13:19:20 +01:00
parent 70c51bb4fe
commit af131189f9

View File

@ -66,13 +66,16 @@ xmpp.on('stanza', async stanza => {
)).catch(console.error) )).catch(console.error)
} }
} else if (stanza.is('iq') && stanza.attrs.type === 'result') { } else if (stanza.is('iq') && stanza.attrs.type === 'result') {
const buf = await imageGenerator.generateBuffer() if (imageGenerator) {
if (imageGenerator && buf.byteLength > 0 && stanza.getChild('slot') && stanza.getChild('slot').getChild('put')) { const buf = await imageGenerator.generateBuffer()
const req = await got.put(stanza.getChild('slot').getChild('put').attrs.url, { if (buf.byteLength > 0 && stanza.getChild('slot')
body: buf && stanza.getChild('slot').getChild('put')) {
}).catch(console.error) const req = await got.put(stanza.getChild('slot').getChild('put').attrs.url, {
if (req && req.url) { body: buf
sendMessage('Su turno: ' + req.url + ' movimiento IA en ' + (time / 1000) + 's') }).catch(console.error)
if (req && req.url) {
sendMessage('Su turno: ' + req.url + ' movimiento IA en ' + (time / 1000) + 's')
}
} }
} }
} }