MCPcopy Create free account
hub / github.com/Xchristech2/Zenitsu-Bot / handleAutotypingForCommand

Function handleAutotypingForCommand

commands/autotyping.js:158–189  ·  view source on GitHub ↗
(sock, chatId)

Source from the content-addressed store, hash-verified

156
157// Function to handle autotyping for commands - BEFORE command execution (not used anymore)
158async 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
192async function showTypingAfterCommand(sock, chatId) {

Callers

nothing calls this directly

Calls 1

isAutotypingEnabledFunction · 0.85

Tested by

no test coverage detected