Class: Fastlane::Actions::TelegramAction

Inherits:
Action
  • Object
show all
Includes:
FastlaneExt
Defined in:
lib/fastlane-ext/telegram.rb

Constant Summary

Constants included from FastlaneExt

FastlaneExt::HTML, FastlaneExt::MARKDOWN, FastlaneExt::VERSION

Documentation collapse

Class Method Summary collapse

Class Method Details

.authorsObject



80
81
82
# File 'lib/fastlane-ext/telegram.rb', line 80

def self.authors
  %w[sroik elfenlaid]
end

.available_optionsObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/fastlane-ext/telegram.rb', line 27

def self.available_options
  [
    FastlaneCore::ConfigItem.new(
      key: :bot_api_token,
      env_name: 'FL_TELEGRAM_BOT_API_TOKEN',
      description: 'API Token for telegram bot',
      verify_block: proc do |value|
        msg = "No bot API token for TelegramAction given, pass using `bot_api_token: 'token'`"
        UI.user_error!(msg) unless value && !value.empty?
      end
    ),
    FastlaneCore::ConfigItem.new(
      key: :message,
      env_name: 'FL_TELEGRAM_MESSAGE',
      description: 'The message that should be displayed on Telegram',
      optional: true
    ),
    FastlaneCore::ConfigItem.new(
      key: :chat_id,
      env_name: 'FL_TELEGRAM_CHAT_ID',
      description: 'telegram chat id',
      verify_block: proc do |value|
        msg = "No chat id for TelegramAction given, pass using `chat_id: 'chat id'`"
        UI.user_error!(msg) unless value && !value.empty?
      end
    ),
    FastlaneCore::ConfigItem.new(
      key: :parse_mode,
      env_name: 'FL_TELEGRAM_MESSAGE_PARSE_MODE',
      description: 'telegram message parse mode',
      optional: true
    ),
    FastlaneCore::ConfigItem.new(
      key: :silent,
      env_name: 'FL_TELEGRAM_MESSAGE_SILENT_NOTIFY',
      description: 'disables telegram message notifications',
      optional: true
    )
  ]
end

.categoryObject



88
89
90
# File 'lib/fastlane-ext/telegram.rb', line 88

def self.category
  :notifications
end

.descriptionObject



19
20
21
# File 'lib/fastlane-ext/telegram.rb', line 19

def self.description
  'Send a success/error message to your Telegram group'
end

.detailsObject



23
24
25
# File 'lib/fastlane-ext/telegram.rb', line 23

def self.details
  'Send a success/error message to your Telegram group'
end

.example_codeObject



68
69
70
71
72
73
74
75
76
77
78
# File 'lib/fastlane-ext/telegram.rb', line 68

def self.example_code
  [
    'telegram(message: "App successfully released!")',
    'telegram(
      bot_api_token: "bot api token here",
      chat_id: "telegram chat id here",
      message: "message here"
      parse_mode: "message parse mode here"
    )'
  ]
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


84
85
86
# File 'lib/fastlane-ext/telegram.rb', line 84

def self.is_supported?(platform)
  platform == :ios
end

.run(params) ⇒ Object



10
11
12
13
# File 'lib/fastlane-ext/telegram.rb', line 10

def self.run(params)
  notifier = TelegramNotifier.new(bot_api_token: params[:bot_api_token], chat_id: params[:chat_id])
  notifier.notify(message: params[:message], parse_mode: params[:parse_mode], silent: params[:silent])
end