@@ -22,7 +22,7 @@ var utils = require('./utils.js');
22
22
var util = require ( 'util' ) ;
23
23
var EventEmitter = require ( 'events' ) . EventEmitter ;
24
24
25
- var formatCommand = function ( name , format , description ) {
25
+ var formatHelpCommand = function ( name , format , description ) {
26
26
var context , template_str , compiled_template , command ;
27
27
28
28
if ( ! format ) {
@@ -34,7 +34,7 @@ var formatCommand = function(name, format, description) {
34
34
'description' : description
35
35
} ;
36
36
37
- template_str = '${format} - ${description}' ;
37
+ template_str = 'hubot ${format} - ${description}' ;
38
38
compiled_template = _ . template ( template_str ) ;
39
39
command = compiled_template ( context ) ;
40
40
@@ -58,7 +58,8 @@ var getRegexForFormatString = function (format) {
58
58
} ;
59
59
60
60
function CommandFactory ( robot ) {
61
- this . robot = robot ;
61
+ var self = this ;
62
+ self . robot = robot ;
62
63
EventEmitter . call ( this ) ;
63
64
}
64
65
@@ -82,9 +83,8 @@ CommandFactory.prototype.addCommand = function (action_alias, messaging_handler)
82
83
var action_alias_name = action_alias . name ;
83
84
84
85
_ . each ( action_alias . formats , function ( format ) {
85
- var formatted_string = formatCommand ( action_alias . name , format . display || format , action_alias . description ) ;
86
- var compiled_template = _ . template ( 'hubot ${command}' ) ;
87
- self . robot . commands . push ( compiled_template ( { robotName : self . robot . name , command : formatted_string } ) ) ;
86
+ var formatted_string = format . display || format ;
87
+ self . robot . commands . push ( formatHelpCommand ( action_alias . name , formatted_string , action_alias . description ) ) ;
88
88
89
89
if ( format . display ) {
90
90
_ . each ( format . representation , function ( representation ) {
@@ -99,6 +99,9 @@ CommandFactory.prototype.addCommand = function (action_alias, messaging_handler)
99
99
100
100
self . robot . listen ( function ( msg ) {
101
101
var i , format_string , regex ;
102
+ if ( ! msg . text ) {
103
+ return false ;
104
+ }
102
105
var command = messaging_handler . normalizeCommand ( msg . text ) ;
103
106
for ( i = 0 ; i < format_strings . length ; i ++ ) {
104
107
format_string = format_strings [ i ] ;
@@ -110,7 +113,7 @@ CommandFactory.prototype.addCommand = function (action_alias, messaging_handler)
110
113
}
111
114
}
112
115
return false ;
113
- } , { id : action_alias_name } , function ( msg ) {
116
+ } , { id : 'st2.' + action_alias_name } , function ( msg ) {
114
117
self . emit ( 'st2.command_match' , {
115
118
msg : msg ,
116
119
alias_name : action_alias_name ,
0 commit comments