diff --git a/README.md b/README.md index bbe1347..23ccb34 100644 --- a/README.md +++ b/README.md @@ -129,7 +129,7 @@ git clone https://github.com/FreeCodeCamp/camperbot.git - Run the following commands to run the app: ```sh -cd campberbot +cd camperbot copy dot-EXAMPLE.env dot.env git submodule update --remote --checkout --init --recursive npm install diff --git a/data/rooms/RoomMessages.js b/data/rooms/RoomMessages.js index 71cecd3..af0bc1e 100644 --- a/data/rooms/RoomMessages.js +++ b/data/rooms/RoomMessages.js @@ -22,12 +22,6 @@ const AllRoomMessages = [ '(https://gitter.im/FreeCodeCamp/HelpBonfires)', not: 'freecodecamp/HelpBonfires' }, - - { - regex: /botx/i, - text: '> you called?' - }, - { regex: /\btroll\b/i, text: '> :trollface: troll problems? [notify admins here]' + @@ -50,8 +44,17 @@ const AllRoomMessages = [ chance: 1 }, { - regex: /\bth?a?n?[xk]s?q?\b/gim, + //tests: https://regex101.com/r/hH5cN7/42 + regex: /(?:^|\s)(?:(?:th(?:n[qx]|x)|t[xyq])|than[kx](?:[sxz]){0,2}(?:[uq]|y(?:ou)?)?)\b/i, func: BotCommands.thanks + }, + { + //tests: https://regex101.com/r/pT0zJ1/3 + regex: /(?:^|\s)(?:love|luv)\s?(?:u|you|me)?,?\s?(?:cbot|@?camperbot)\b/i, + func: function(input) { + const fromUser = '@' + input.message.model.fromUser.username; + return fromUser + ', :sparkles: :heart_eyes: :sparkles:'; + } } ]; diff --git a/lib/bot/GBot.js b/lib/bot/GBot.js index 5664aa2..f18d1fe 100644 --- a/lib/bot/GBot.js +++ b/lib/bot/GBot.js @@ -108,7 +108,7 @@ const GBot = { listReplyOptionsAvailable = this.findListOption(input); let output; - if (input.command) { + if (input.command && BotCommands.hasOwnProperty(input.keyword) && typeof BotCommands[input.keyword] === 'function') { // this looks up a command and calls it output = BotCommands[input.keyword](input, this); } else if (listReplyOptionsAvailable !== false) { diff --git a/lib/bot/cmds/thanks.js b/lib/bot/cmds/thanks.js index 568bc54..20c033f 100644 --- a/lib/bot/cmds/thanks.js +++ b/lib/bot/cmds/thanks.js @@ -6,15 +6,15 @@ const Utils = require('../../../lib/utils/Utils'), const thanksCommands = { - messages: { - wikiHint: function(fromUser) { - const wikiUrl = '(https://github.com/freecodecamp/' + - 'freecodecamp/wiki/wiki-style-guide)'; - - return '\n> hey @' + fromUser + ' if you found this info helpful ' + - ':point_right: *[consider adding a wiki article!]' + wikiUrl + '*'; - } - }, + // messages: { + // wikiHint: function(fromUser) { + // const wikiUrl = '(https://github.com/freecodecamp/' + + // 'freecodecamp/wiki/wiki-style-guide)'; + // + // return '\n> hey @' + fromUser + ' if you found this info helpful ' + + // ':point_right: *[consider adding a wiki article!]' + wikiUrl + '*'; + // } + // }, thanks: function(input, bot) { Utils.hasProperty(input, 'message', 'thanks expects an object'); @@ -105,8 +105,9 @@ const thanksCommands = { try { const username = blob.response.about.username, about = blob.response.about, + brownieEmoji = about.browniePoints < 999 ? ':cookie:' : ':star2:', uri = 'http://www.freecodecamp.com/' + username; - str = '> :star: ' + about.browniePoints + ' | @' + username + ' | '; + str = `> ${brownieEmoji} ${about.browniePoints} | @${username} |`; str += TextLib.mdLink(uri, uri); } catch (err) { Utils.error('can\'t create response from API callback', err);