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:
parent
e18193c1a2
commit
8a3097f63e
8 changed files with 110 additions and 27 deletions
|
@ -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}`);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue