FIX: Discobot mention tutorial should be case insensitive.

FIX: Discobot mention tutorial should be case insensitive.

diff --git a/plugins/discourse-narrative-bot/lib/discourse_narrative_bot/actions.rb b/plugins/discourse-narrative-bot/lib/discourse_narrative_bot/actions.rb
index 349aedd..ca75d08 100644
--- a/plugins/discourse-narrative-bot/lib/discourse_narrative_bot/actions.rb
+++ b/plugins/discourse-narrative-bot/lib/discourse_narrative_bot/actions.rb
@@ -69,7 +69,10 @@ module DiscourseNarrativeBot
       valid = false
 
       doc.css(".mention").each do |mention|
-        valid = true if mention.text == "@#{self.discobot_user.username}"
+        if mention.text.downcase == "@#{self.discobot_user.username}".downcase
+          valid = true
+          break
+        end
       end
 
       valid
diff --git a/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/new_user_narrative_spec.rb b/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/new_user_narrative_spec.rb
index a74ca8b..5fca22b 100644
--- a/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/new_user_narrative_spec.rb
+++ b/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/new_user_narrative_spec.rb
@@ -803,7 +803,7 @@ describe DiscourseNarrativeBot::NewUserNarrative do
 
       it 'should create the right reply' do
         post.update!(
-          raw: '@discobot hello how are you doing today?'
+          raw: '@disCoBot hello how are you doing today?'
         )
 
         narrative.expects(:enqueue_timeout_job).with(user)

GitHub sha: 329969ea

1 Like

This commit has been mentioned on Discourse Meta. There might be relevant details there:

The following would be even better if you want to make sure it works with all kinds of Unicode usernames.

if User.normalize_username(mention.text) == "@#{self.discobot_user.username_lower}"
1 Like

Follow up to 329969ea20296b74b77e8e568e63f635cefa7b3a.