lib/lita/handlers/jira.rb in lita-jira-0.7.0 vs lib/lita/handlers/jira.rb in lita-jira-0.7.1

- old
+ new

@@ -1,10 +1,11 @@ # lita-jira plugin module Lita # Because we can. module Handlers # Main handler + # rubocop:disable Metrics/ClassLength class Jira < Handler namespace 'Jira' config :username, required: true, type: String config :password, required: true, type: String @@ -112,20 +113,25 @@ response.reply(format_issues(issues)) end def ambient(response) - return if invalid_ambient(response) + return if invalid_ambient?(response) issue = fetch_issue(response.match_data['issue'], false) response.reply(format_issue(issue)) if issue end private - def invalid_ambient(response) - response.message.command? || !config.ambient || config.ignore.include?(response.user.name) || (config.rooms && !config.rooms.include?(response.message.source.room)) + def invalid_ambient?(response) + response.message.command? || !config.ambient || ignored?(response.user) || (config.rooms && !config.rooms.include?(response.message.source.room)) end + + def ignored?(user) + config.ignore.include?(user.id) || config.ignore.include?(user.mention_name) || config.ignore.include?(user.name) + end # rubocop:enable Metrics/AbcSize end + # rubocop:enable Metrics/ClassLength Lita.register_handler(Jira) end end