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)
}
} else if (stanza.is('iq') && stanza.attrs.type === 'result') {
const buf = await imageGenerator.generateBuffer()
if (imageGenerator && buf.byteLength > 0 && stanza.getChild('slot') && stanza.getChild('slot').getChild('put')) {
const req = await got.put(stanza.getChild('slot').getChild('put').attrs.url, {
body: buf
}).catch(console.error)
if (req && req.url) {
sendMessage('Su turno: ' + req.url + ' movimiento IA en ' + (time / 1000) + 's')
if (imageGenerator) {
const buf = await imageGenerator.generateBuffer()
if (buf.byteLength > 0 && stanza.getChild('slot')
&& stanza.getChild('slot').getChild('put')) {
const req = await got.put(stanza.getChild('slot').getChild('put').attrs.url, {
body: buf
}).catch(console.error)
if (req && req.url) {
sendMessage('Su turno: ' + req.url + ' movimiento IA en ' + (time / 1000) + 's')
}
}
}
}