UNPKG

pockybot

Version:

Spark bot that handles team recognition

36 lines (35 loc) 1.61 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const trigger_1 = require("../../models/trigger"); const constants_1 = require("../../constants"); const command_1 = require("../../models/command"); const xmlMessageParser_1 = require("../parsers/xmlMessageParser"); class Keywords extends trigger_1.default { constructor(config) { super(); this.config = config; } isToTriggerOn(message) { let parsedMessage = xmlMessageParser_1.default.parseNonPegMessage(message); return parsedMessage.botId === constants_1.default.botId && parsedMessage.command.toLowerCase() === command_1.Command.Keywords; } isToTriggerOnPM(message) { return message.text.toLowerCase().trim() === command_1.Command.Keywords; } async createMessage() { let newMessage = '## Here is the list of possible keywords to include in your message\n\n'; this.config.getStringConfig('keyword').forEach(item => { newMessage += `* ${item}\n`; }); const penaltyKeywords = this.config.getStringConfig('penaltyKeyword'); if (penaltyKeywords.length > 0) { newMessage += '\n## Here is the list of keywords that can be used to apply a penalty to the sender\n\n'; newMessage += 'Penalty keywords do not count against the peg limit, and are *not* applied to messages that also include standard keywords.\n\n'; newMessage += penaltyKeywords.map(keyword => `* ${keyword}\n`); } return { markdown: newMessage }; } } exports.default = Keywords;