FIX: allow extra whitespace when asking discobot to perform a bot command (#17738)
This commit is contained in:
parent
6e682cc7c4
commit
542cd1ff90
|
@ -227,7 +227,7 @@ module DiscourseNarrativeBot
|
|||
@@cooked_triggers = {}
|
||||
|
||||
def cook(trigger)
|
||||
@@cooked_triggers[trigger] ||= PrettyText.cook("@#{self.discobot_username} #{trigger}")
|
||||
@@cooked_triggers[trigger] ||= PrettyText.cook("@#{self.discobot_username}\\s+#{trigger}")
|
||||
end
|
||||
|
||||
def match_trigger?(trigger)
|
||||
|
|
|
@ -591,6 +591,17 @@ RSpec.describe DiscourseNarrativeBot::TrackSelector do
|
|||
))
|
||||
end
|
||||
|
||||
it 'should ignore extra whitespace proceeding the mention' do
|
||||
post.update!(raw: '@discobot roll 2d1')
|
||||
described_class.new(:reply, user, post_id: post.id).select
|
||||
new_post = Post.last
|
||||
|
||||
expect(new_post.raw).to eq(
|
||||
I18n.t("discourse_narrative_bot.dice.results",
|
||||
results: '1, 1'
|
||||
))
|
||||
end
|
||||
|
||||
context 'when dice roll is requested incorrectly' do
|
||||
it 'should create the right reply' do
|
||||
post.update!(raw: 'roll 2d1 @discobot')
|
||||
|
|
Loading…
Reference in New Issue