3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-18 07:35:02 +00:00

Add a generic bot alert log type. Use this in several places.

This commit is contained in:
Dragory 2019-05-04 19:18:16 +03:00
parent e18193c1a2
commit 8a3097f63e
8 changed files with 110 additions and 27 deletions

View file

@ -169,7 +169,7 @@ export class LogsPlugin extends ZeppelinPlugin<ILogsPluginConfig> {
let formatted;
try {
formatted = await renderTemplate(format, {
const values = {
...data,
userMention: async userOrMember => {
if (!userOrMember) return "";
@ -217,7 +217,16 @@ export class LogsPlugin extends ZeppelinPlugin<ILogsPluginConfig> {
return result;
},
});
};
if (type === LogType.BOT_ALERT) {
const valuesWithoutTmplEval = { ...values };
values.tmplEval = str => {
return renderTemplate(str, valuesWithoutTmplEval);
};
}
formatted = await renderTemplate(format, values);
} catch (e) {
if (e instanceof TemplateParseError) {
logger.error(`Error when parsing template:\nError: ${e.message}\nTemplate: ${format}`);