FIX: match discobot triggers on cooked version

In French, the help trigger has a raw content of "afficher l'aider" which is then cooked into "afficher l’aide" (note the different quote character).
Since we were checking the raw content of the trigger against the cooked version of the post, this trigger never worked in French.

This changes so that we cook the trigger before checking in against the cooked version of the post.

DEV: new 'discobot_username' method that is used everywhere instead of 'discobot_user.username' / 'discobot_user.username_lower'
This commit is contained in:
Régis Hanol
2020-06-25 13:29:55 +02:00
parent 689568c216
commit 3c31884b79
9 changed files with 47 additions and 46 deletions

View File

@ -8,6 +8,10 @@ module DiscourseNarrativeBot
@discobot ||= User.find(-2)
end
def discobot_username
self.discobot_user.username_lower
end
private
def reply_to(post, raw, opts = {}, post_alert_options = {})
@ -73,7 +77,7 @@ module DiscourseNarrativeBot
valid = false
doc.css(".mention").each do |mention|
if User.normalize_username(mention.text) == "@#{self.discobot_user.username_lower}"
if User.normalize_username(mention.text) == "@#{self.discobot_username}"
valid = true
break
end