From d914e8a7177a12dbfc2d1428939da50408c77d05 Mon Sep 17 00:00:00 2001 From: Dragory Date: Sat, 16 Mar 2019 16:18:28 +0200 Subject: [PATCH] Tags: switch from %arg syntax to regular template variable format with indexes, e.g. {args.0} --- src/plugins/Tags.ts | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/src/plugins/Tags.ts b/src/plugins/Tags.ts index 951a09e3..5cf5ae98 100644 --- a/src/plugins/Tags.ts +++ b/src/plugins/Tags.ts @@ -7,6 +7,7 @@ import { SavedMessage } from "../data/entities/SavedMessage"; import moment from "moment-timezone"; import humanizeDuration from "humanize-duration"; import { ZeppelinPlugin } from "./ZeppelinPlugin"; +import { renderTemplate } from "../templateFormatter"; const TAG_FUNCTIONS = { countdown(toDate) { @@ -140,20 +141,12 @@ export class TagsPlugin extends ZeppelinPlugin supports quotes etc.) const variableStr = msg.data.content.slice(prefix.length + tagName.length).trim(); - const variableValues = this.commands.parseArguments(variableStr).map(v => v.value); - let variableIndex = 0; - body = body.replace(/(? variableValues[variableIndex++] || ""); + const tagArgs = this.commands.parseArguments(variableStr).map(v => v.value); - // Run functions - body = body.replace(/(? { - if (!TAG_FUNCTIONS[fn]) return ""; - const fnArgs = args ? args.split(/(?