Skip to content
This repository has been archived by the owner on Oct 20, 2018. It is now read-only.

Fix/thanks #78

Merged
merged 14 commits into from May 1, 2016
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 10 additions & 7 deletions data/rooms/RoomMessages.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]' +
Expand All @@ -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,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This regex seems perfect. 👍

Pending Test

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) {
Copy link
Member

@abhisekp abhisekp Apr 25, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@noncentz please write a documentation in a comment about the command i.e. what it does and when it does, etc.
E.g.

/**
* This command loves camperbot.
**/

const fromUser = '@' + input.message.model.fromUser.username;
return fromUser + ', :sparkles: :heart_eyes: :sparkles:';
}
}
];

Expand Down
2 changes: 1 addition & 1 deletion lib/bot/GBot.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
21 changes: 11 additions & 10 deletions lib/bot/cmds/thanks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Copy link
Member

@abhisekp abhisekp Apr 25, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pending: Test this in bonfire rooms

Pending Test

// 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');
Expand Down Expand Up @@ -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);
Expand Down