(sock, chatId)
| 156 | |
| 157 | // Function to handle autotyping for commands - BEFORE command execution (not used anymore) |
| 158 | async function handleAutotypingForCommand(sock, chatId) { |
| 159 | if (isAutotypingEnabled()) { |
| 160 | try { |
| 161 | // First subscribe to presence updates for this chat |
| 162 | await sock.presenceSubscribe(chatId); |
| 163 | |
| 164 | // Send available status first |
| 165 | await sock.sendPresenceUpdate('available', chatId); |
| 166 | await new Promise(resolve => setTimeout(resolve, 500)); |
| 167 | |
| 168 | // Then send the composing status |
| 169 | await sock.sendPresenceUpdate('composing', chatId); |
| 170 | |
| 171 | // Keep typing indicator active for commands with increased duration |
| 172 | const commandTypingDelay = 3000; |
| 173 | await new Promise(resolve => setTimeout(resolve, commandTypingDelay)); |
| 174 | |
| 175 | // Send composing again to ensure it stays visible |
| 176 | await sock.sendPresenceUpdate('composing', chatId); |
| 177 | await new Promise(resolve => setTimeout(resolve, 1500)); |
| 178 | |
| 179 | // Finally send paused status |
| 180 | await sock.sendPresenceUpdate('paused', chatId); |
| 181 | |
| 182 | return true; // Indicates typing was shown |
| 183 | } catch (error) { |
| 184 | console.error('❌ Error sending command typing indicator:', error); |
| 185 | return false; // Indicates typing failed |
| 186 | } |
| 187 | } |
| 188 | return false; // Autotyping is disabled |
| 189 | } |
| 190 | |
| 191 | // Function to show typing status AFTER command execution |
| 192 | async function showTypingAfterCommand(sock, chatId) { |
nothing calls this directly
no test coverage detected