debian-mirror-gitlab/lib/gitlab/chat/responder.rb

23 lines
580 B
Ruby
Raw Normal View History

2019-07-07 11:18:12 +05:30
# frozen_string_literal: true
module Gitlab
module Chat
module Responder
# Returns an instance of the responder to use for generating chat
# responses.
#
# This method will return `nil` if no formatter is available for the given
# build.
#
# build - A `Ci::Build` that executed a chat command.
def self.responder_for(build)
2021-06-08 01:23:25 +05:30
integration = build.pipeline.chat_data&.chat_name&.integration
2019-07-07 11:18:12 +05:30
2021-06-08 01:23:25 +05:30
if (responder = integration.try(:chat_responder))
2019-07-07 11:18:12 +05:30
responder.new(build)
end
end
end
end
end