2017-10-02 12:09:44 +03:30
|
|
|
|
'use strict';
|
|
|
|
|
|
2017-10-31 22:20:49 +01:00
|
|
|
|
// Utils
|
|
|
|
|
const { scheduleDeletion } = require('../../utils/tg');
|
2017-10-02 12:35:40 +03:30
|
|
|
|
|
2017-10-02 12:09:44 +03:30
|
|
|
|
// DB
|
|
|
|
|
const { managesGroup } = require('../../stores/group');
|
|
|
|
|
|
2020-03-10 22:10:48 +01:00
|
|
|
|
/** @param { import('../../typings/context').ExtendedContext } ctx */
|
2021-05-07 22:46:11 +02:00
|
|
|
|
const linkHandler = async (ctx, next) => {
|
|
|
|
|
if (ctx.chat.type === 'private') {
|
2018-02-17 22:19:00 +01:00
|
|
|
|
return next();
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-07 22:46:11 +02:00
|
|
|
|
const group = await managesGroup({ id: ctx.chat.id });
|
2017-10-02 12:09:44 +03:30
|
|
|
|
|
2021-05-07 22:46:11 +02:00
|
|
|
|
return ctx.replyWithHTML(group.link || '️ℹ️ <b>No link to this group</b>', {
|
2020-05-11 13:31:36 +02:00
|
|
|
|
disable_web_page_preview: false,
|
|
|
|
|
}).then(scheduleDeletion());
|
2017-10-02 12:09:44 +03:30
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
module.exports = linkHandler;
|