// this regex extracts ussd reply options const regex = /\s(\d{1,2}).\s/g; // TODO: converts the text to a telegram keyboard function createKeyboard(input) { return Array.from(input.matchAll(regex), (m) => [m[1]]); } // parses ussd responses to code and text function parseUssdResponse(input) { return { code: input.slice(0, 3), text: input.slice(4), keyboard: createKeyboard(input), }; } module.exports = { createKeyboard, parseUssdResponse, };