2017-07-24 17:12:38 +02:00
|
|
|
'use strict';
|
|
|
|
|
2017-09-24 14:55:26 +02:00
|
|
|
const escapeHtml = s => s
|
|
|
|
.replace(/</g, '<');
|
|
|
|
|
|
|
|
const link = ({ id, first_name }) =>
|
|
|
|
`<a href="tg://user?id=${id}">${escapeHtml(first_name)}</a>`;
|
2017-07-24 17:12:38 +02:00
|
|
|
|
2017-10-22 17:33:21 +02:00
|
|
|
const quietLink = (user) =>
|
|
|
|
user.username
|
|
|
|
? `<a href="t.me/${user.username}">${escapeHtml(user.first_name)}</a>`
|
|
|
|
: link(user);
|
|
|
|
|
2017-10-04 23:57:47 +05:30
|
|
|
/**
|
|
|
|
* @param {number} ms
|
|
|
|
* Deletes messages after (ms) milliseconds
|
|
|
|
* @returns {undefined}
|
|
|
|
*/
|
2017-07-24 18:08:31 +02:00
|
|
|
const deleteAfter = ms => ctx =>
|
|
|
|
setTimeout(() =>
|
|
|
|
ctx.telegram.deleteMessage(ctx.chat.id, ctx.message.message_id),
|
|
|
|
ms);
|
|
|
|
|
2017-07-24 17:12:38 +02:00
|
|
|
module.exports = {
|
2017-07-24 18:08:31 +02:00
|
|
|
deleteAfter,
|
2017-09-24 23:23:13 +02:00
|
|
|
escapeHtml,
|
2017-10-22 17:33:21 +02:00
|
|
|
link,
|
|
|
|
quietLink,
|
2017-07-24 17:12:38 +02:00
|
|
|
};
|