(chatUpdate)
| 14 | }, ms)) |
| 15 | |
| 16 | export async function handler(chatUpdate) { |
| 17 | // Initialize variables |
| 18 | this.msgqueque = this.msgqueque || [] |
| 19 | this.uptime = this.uptime || Date.now() |
| 20 | |
| 21 | // Get connection |
| 22 | const conn = this |
| 23 | |
| 24 | // Define opts if not defined |
| 25 | const opts = global.opts || { |
| 26 | self: false, |
| 27 | autoread: false, |
| 28 | restrict: false, |
| 29 | noprint: false, |
| 30 | swonly: false, |
| 31 | nyimak: false, |
| 32 | queque: false |
| 33 | } |
| 34 | |
| 35 | if (!chatUpdate) |
| 36 | return |
| 37 | |
| 38 | // Push messages to queue |
| 39 | if (this.pushMessage) { |
| 40 | this.pushMessage(chatUpdate.messages).catch(console.error) |
| 41 | } |
| 42 | |
| 43 | let m = chatUpdate.messages[chatUpdate.messages.length - 1] |
| 44 | if (!m) |
| 45 | return |
| 46 | |
| 47 | // Load database if not loaded |
| 48 | if (global.db && global.db.data == null) |
| 49 | await global.loadDatabase() |
| 50 | |
| 51 | // Define currency |
| 52 | const moneda = global.moneda || 'coins' |
| 53 | |
| 54 | try { |
| 55 | m = smsg(this, m) || m |
| 56 | if (!m) |
| 57 | return |
| 58 | |
| 59 | // Handle status broadcasts |
| 60 | if (m.chat === 'status@broadcast') { |
| 61 | await this.readMessages([m.key]).catch(() => {}) |
| 62 | console.log(`Viewed status from: ${m.sender}`) |
| 63 | return |
| 64 | } |
| 65 | |
| 66 | // Initialize message properties |
| 67 | m.exp = 0 |
| 68 | m.coin = false |
| 69 | |
| 70 | console.log('════════════════════════════') |
| 71 | console.log('📨 MESSAGE RECEIVED') |
| 72 | console.log('════════════════════════════') |
| 73 | console.log('Chat:', m.chat) |
nothing calls this directly
no test coverage detected