lib/lita/message.rb in lita-2.6.0 vs lib/lita/message.rb in lita-2.7.0
- old
+ new
@@ -23,10 +23,16 @@
def initialize(robot, body, source)
@robot = robot
@body = body
@source = source
- @command = !!@body.sub!(/^\s*@?#{@robot.mention_name}[:,]?\s*/i, "")
+ name_pattern = Regexp.escape(@robot.mention_name)
+
+ if @robot.alias
+ name_pattern = "#{name_pattern}|#{Regexp.escape(@robot.alias)}"
+ end
+
+ @command = !!@body.sub!(/^\s*@?(?:#{name_pattern})[:,]?\s*/i, "")
end
# An array of arguments created by shellsplitting the message body, as if
# it were a shell command.
# @return [Array<String>] The array of arguments.