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.
35 lines
688 B
35 lines
688 B
6 years ago
|
const success = response => ctx => response ? ctx.reply(response) : null;
|
||
|
const { EOL } = require('os');
|
||
|
const { path } = require('../util/index.js');
|
||
|
|
||
|
const convertCtx = ctx => {
|
||
|
const message = path(['update', 'message'], ctx);
|
||
|
const { id, first_name, username, language_code } = path(['from'], message);
|
||
|
const { text } = message;
|
||
|
return JSON.stringify({
|
||
|
id,
|
||
|
first_name,
|
||
|
username,
|
||
|
language_code,
|
||
|
text,
|
||
|
}, null, 2);
|
||
|
};
|
||
|
|
||
|
const fail = response => ctx => {
|
||
|
if(!response
|
||
|
|| !path(['update', 'message'], ctx)
|
||
|
) return;
|
||
|
console.log(
|
||
|
EOL,
|
||
|
response,
|
||
|
EOL,
|
||
|
`With context: `,
|
||
|
convertCtx(ctx),
|
||
|
);
|
||
|
return ctx.reply(response);
|
||
|
};
|
||
|
|
||
|
module.exports = {
|
||
|
success, fail,
|
||
|
};
|