MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / findCommand

Function findCommand

src/bot/commands.ts:157–165  ·  view source on GitHub ↗
(text: string)

Source from the content-addressed store, hash-verified

155
156/** Look up a command by the leading `/word` (case-insensitive). `/start` aliases `/help`. */
157export function findCommand(text: string): { cmd: BotCommand; args: string } | null {
158 if (!text.startsWith('/')) return null;
159 const sp = text.indexOf(' ');
160 let word = (sp === -1 ? text.slice(1) : text.slice(1, sp)).toLowerCase();
161 const args = sp === -1 ? '' : text.slice(sp + 1).trim();
162 if (word === 'start') word = 'help';
163 const cmd = COMMANDS.find(c => c.name === word);
164 return cmd ? { cmd, args } : null;
165}
166
167/** The list an adapter registers as the native `/` menu. */
168export function menuDescriptors(): { command: string; description: string }[] {

Callers 2

onMessageMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected