(text: string)
| 155 | |
| 156 | /** Look up a command by the leading `/word` (case-insensitive). `/start` aliases `/help`. */ |
| 157 | export 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. */ |
| 168 | export function menuDescriptors(): { command: string; description: string }[] { |
no outgoing calls
no test coverage detected