Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
match only beginning of the lines
Browse files Browse the repository at this point in the history
should prevent matching random messages that happen to have the command
somewhere in the middle
  • Loading branch information
Michael Bumann committed Feb 2, 2016
1 parent 43639b3 commit be09602
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/openassets.js
Expand Up @@ -97,7 +97,7 @@ module.exports = function(robot) {
}
};

robot.hear(new RegExp(`${robotKeyword} address (add|remove|list)\\s*([a-zA-Z0-9_\-]*)\\s*([a-zA-Z0-9_\-]*)`, 'i'), function(res) {
robot.hear(new RegExp(`^${robotKeyword} address (add|remove|list)\\s*([a-zA-Z0-9_\-]*)\\s*([a-zA-Z0-9_\-]*)`, 'i'), function(res) {
let command = res.match[1];
let nick = res.match[2];
let address = res.match[3];
Expand Down Expand Up @@ -169,7 +169,7 @@ module.exports = function(robot) {
return Base58.encode(btcBuff.buffer());
}

robot.hear(new RegExp(`${robotKeyword} show (\\S+)`, 'i'), function(hearResponse) {
robot.hear(new RegExp(`^${robotKeyword} show (\\S+)`, 'i'), function(hearResponse) {
balanceOf(hearResponse.match[1], function(assetDetails) {
if (assetDetails) {
let msg = `${hearResponse.match[1]} has ${totalBalanceOfAsset(assetDetails)} ${robotKeyword}`;
Expand All @@ -180,7 +180,7 @@ module.exports = function(robot) {
});
});

robot.hear(new RegExp(`${robotKeyword} list`, 'i'), function(hearResponse) {
robot.hear(new RegExp(`^${robotKeyword} list`, 'i'), function(hearResponse) {
let assetUrl = 'https://api.coinprism.com/v1/assets/' + process.env.OA_ASSET_ID + '/owners';

robot.http(assetUrl).header('Content-Type', 'application/json')
Expand Down Expand Up @@ -243,7 +243,7 @@ module.exports = function(robot) {

});

robot.hear(new RegExp(`${robotKeyword} send (\\d*)\\s?to (\\S+)`, 'i'), function(hearResponse) {
robot.hear(new RegExp(`^${robotKeyword} send (\\d*)\\s?to (\\S+)`, 'i'), function(hearResponse) {
let user = hearResponse.message.user;

if (!robot.auth.isAdmin(user)) {
Expand Down

0 comments on commit be09602

Please sign in to comment.