2019-11-12 13:53:58 +00:00
|
|
|
module.exports = Self => {
|
2022-02-22 06:30:26 +00:00
|
|
|
require('../methods/chat/getServiceAuth')(Self);
|
2020-01-20 06:33:24 +00:00
|
|
|
require('../methods/chat/send')(Self);
|
|
|
|
require('../methods/chat/sendCheckingPresence')(Self);
|
2021-02-01 08:29:47 +00:00
|
|
|
require('../methods/chat/notifyIssues')(Self);
|
2022-06-02 12:55:39 +00:00
|
|
|
require('../methods/chat/sendQueued')(Self);
|
2022-11-25 07:36:29 +00:00
|
|
|
|
|
|
|
Self.observe('before save', async function(ctx) {
|
|
|
|
if (!ctx.isNewInstance) return;
|
|
|
|
|
|
|
|
let {message} = ctx.instance;
|
|
|
|
if (!message) return;
|
|
|
|
|
2022-11-25 08:18:21 +00:00
|
|
|
const parts = message.match(/(?<=\[).*(?=])/g);
|
2022-11-25 07:36:29 +00:00
|
|
|
const replacedParts = parts.map(part => {
|
|
|
|
return part.replace(/[*()]/g, '');
|
|
|
|
});
|
|
|
|
|
|
|
|
for (const [index, part] of parts.entries())
|
|
|
|
message = message.replace(part, replacedParts[index]);
|
|
|
|
|
|
|
|
ctx.instance.message = message;
|
|
|
|
});
|
2019-11-12 13:53:58 +00:00
|
|
|
};
|