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

Function extractUserInfo

commands/chatbot.js:49–68  ·  view source on GitHub ↗
(message)

Source from the content-addressed store, hash-verified

47
48// Extract user information from messages
49function 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
70async function handleChatbotCommand(sock, chatId, message, match) {
71 if (!match) {

Callers 1

handleChatbotResponseFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected