(message)
| 47 | |
| 48 | // Extract user information from messages |
| 49 | function extractUserInfo(message) { |
| 50 | const info = {}; |
| 51 | |
| 52 | // Extract name |
| 53 | if (message.toLowerCase().includes('my name is')) { |
| 54 | info.name = message.split('my name is')[1].trim().split(' ')[0]; |
| 55 | } |
| 56 | |
| 57 | // Extract age |
| 58 | if (message.toLowerCase().includes('i am') && message.toLowerCase().includes('years old')) { |
| 59 | info.age = message.match(/\d+/)?.[0]; |
| 60 | } |
| 61 | |
| 62 | // Extract location |
| 63 | if (message.toLowerCase().includes('i live in') || message.toLowerCase().includes('i am from')) { |
| 64 | info.location = message.split(/(?:i live in|i am from)/i)[1].trim().split(/[.,!?]/)[0]; |
| 65 | } |
| 66 | |
| 67 | return info; |
| 68 | } |
| 69 | |
| 70 | async function handleChatbotCommand(sock, chatId, message, match) { |
| 71 | if (!match) { |
no outgoing calls
no test coverage detected