Telegram Shell. Remote access over Telegram bot API.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

20 lines
484 B

const path = (path, obj) => path.reduce((result, segment) => result && result[segment], obj);
const compose = (...fns) => fns.reduce((f, g) => (...args) => f(g(...args)));
const getText = ctx => path(['update', 'message', 'text'], ctx) || '';
const removeCommand = cmd => text => text.replace(`/${cmd}`, '').trim();
const extractCommandText = cmd => ctx =>
compose(
removeCommand(cmd),
getText,
)(ctx);
module.exports = {
path,
compose,
getText,
extractCommandText,
};