Class: Fastlane::Actions::SqCiToolsSendTelegramMessageAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/sq_ci_tools/actions/sq_ci_tools_send_telegram_message_action.rb

Class Method Summary collapse

Class Method Details

.authorsObject



55
56
57
# File 'lib/fastlane/plugin/sq_ci_tools/actions/sq_ci_tools_send_telegram_message_action.rb', line 55

def self.authors
  ['Semen Kologrivov']
end

.available_optionsObject



39
40
41
42
43
44
45
46
47
48
49
# File 'lib/fastlane/plugin/sq_ci_tools/actions/sq_ci_tools_send_telegram_message_action.rb', line 39

def self.available_options
  [
    FastlaneCore::ConfigItem.new(
      key: :message,
      description: 'Message for send',
      optional: false,
      type: String
    )
  ] +
    Options::Telegram.options
end

.descriptionObject



31
32
33
# File 'lib/fastlane/plugin/sq_ci_tools/actions/sq_ci_tools_send_telegram_message_action.rb', line 31

def self.description
  'Send message via Telegram'
end

.detailsObject



35
36
37
# File 'lib/fastlane/plugin/sq_ci_tools/actions/sq_ci_tools_send_telegram_message_action.rb', line 35

def self.details
  ''
end

.is_supported?(_) ⇒ Boolean

Returns:

  • (Boolean)


59
60
61
# File 'lib/fastlane/plugin/sq_ci_tools/actions/sq_ci_tools_send_telegram_message_action.rb', line 59

def self.is_supported?(_)
  true
end

.return_valueObject



51
52
53
# File 'lib/fastlane/plugin/sq_ci_tools/actions/sq_ci_tools_send_telegram_message_action.rb', line 51

def self.return_value
  ''
end

.run(params) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/fastlane/plugin/sq_ci_tools/actions/sq_ci_tools_send_telegram_message_action.rb', line 9

def self.run(params)
  access_token = params[:telegram_access_token]
  chat_ids = params[:telegram_chat_ids]
  if access_token.nil? || access_token == "" || chat_ids.nil? || chat_ids == ""
    return
  end

  uri = URI.parse("https://api.telegram.org/bot#{access_token}/sendMessage")
  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = true

  chat_ids.split(',').each do |chat_id|
    request = Net::HTTP::Post::Multipart.new(uri, {
      "chat_id" => chat_id,
      "text" => params[:message],
      "parse_mode" => params[:telegram_parse_mode]
    })

    http.request(request)
  end
end