Class: Fastlane::Actions::ZeevaDiscordAction

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

Class Method Summary collapse

Class Method Details

.authorsObject



52
53
54
# File 'lib/fastlane/plugin/zeeva_discord/actions/zeeva_discord_action.rb', line 52

def self.authors
  ["Yazan Tarifi"]
end

.available_optionsObject



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/fastlane/plugin/zeeva_discord/actions/zeeva_discord_action.rb', line 65

def self.available_options
  [
    FastlaneCore::ConfigItem.new(
      key: :server_token,
      env_name: "SERVER_TOKEN",
      description: "The Private Current Server Token",
      optional: false,
      type: String
    ),
    FastlaneCore::ConfigItem.new(
      key: :client_id,
      env_name: "CLIENT_ID",
      description: "The Client ID for Your Bot",
      optional: false,
      type: String
    ),
    FastlaneCore::ConfigItem.new(
      key: :channel_id,
      env_name: "CHANNEL_ID",
      description: "The Target Channel ID The Bot Will Send the Message on",
      optional: false,
      type: String
    ),
    FastlaneCore::ConfigItem.new(
      key: :build_name,
      env_name: "BUILD_NAME",
      description: "The Build Name that Currently Running",
      optional: false,
      type: String
    ),
    FastlaneCore::ConfigItem.new(
      key: :build_type,
      env_name: "BUILD_TYPE",
      description: "The Build Type that Currently Running",
      optional: false,
      type: String
    ),
    FastlaneCore::ConfigItem.new(
      key: :platform_code,
      env_name: "PLATFORM_CODE",
      description: "The Platform that Currently Running Ex: Android, IOS, Mac",
      optional: false,
      type: String
    )
  ]
end

.descriptionObject



48
49
50
# File 'lib/fastlane/plugin/zeeva_discord/actions/zeeva_discord_action.rb', line 48

def self.description
  "Fastlane Plugin to Send Messages about Builds from Android, IOS Applications Via Fastlane"
end

.detailsObject



60
61
62
63
# File 'lib/fastlane/plugin/zeeva_discord/actions/zeeva_discord_action.rb', line 60

def self.details
  # Optional:
  "Fastlane Plugin To Send Messages on Channels in Discord Private Server to Notify the Team once New Build Sent and You can Provide Custom Messages, Titles and Message Content With Json File Configuration and This Task Will be Started once you Push new Build from Your Mobile Application via Fastlane Task"
end

.get_message_body(buildName, buildType, platform, buildContent) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/fastlane/plugin/zeeva_discord/actions/zeeva_discord_action.rb', line 28

def self.get_message_body(buildName, buildType, platform, buildContent)
  return "====== New Build ======" +
    "\n" +
    "Build Name : " +
    buildName + "\n" +
    "Build Type : " + buildType +
    "\n" + "Platform : " + platform + "\n" +
    "Build Content : " + buildContent +
    "\n" +
    "====== New Build ======"
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


112
113
114
115
# File 'lib/fastlane/plugin/zeeva_discord/actions/zeeva_discord_action.rb', line 112

def self.is_supported?(platform)
  [:ios, :mac, :android].include?(platform)
  true
end

.return_valueObject



56
57
58
# File 'lib/fastlane/plugin/zeeva_discord/actions/zeeva_discord_action.rb', line 56

def self.return_value
  # If your method provides a return value, you can describe here what it does
end

.run(params) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/fastlane/plugin/zeeva_discord/actions/zeeva_discord_action.rb', line 8

def self.run(params)
  serverToken = params[:server_token]
  applicationId = params[:client_id]
  channelId = params[:channel_id]
  buildName = params[:build_name]
  buildType = params[:build_type]
  platformCode = params[:platform_code]

  file_content = File.read('zeevaBuild.md');
  buildContent = file_content

  UI.message("Zeeva Fastlane Plugin - Discord Configuration - Started !!")
  UI.message("=========================== Bot Credentials ===========================")
  UI.message("Channel Id : " + channelId)
  UI.message("Application Id : " + applicationId)
  UI.message("Server Token : " + serverToken)
  UI.message("=======================================================================")
  run_application_bot(serverToken, applicationId, channelId, get_message_body(buildName, buildType, platformCode, buildContent))
end

.run_application_bot(token, appId, channelId, messageBody) ⇒ Object



40
41
42
43
44
45
46
# File 'lib/fastlane/plugin/zeeva_discord/actions/zeeva_discord_action.rb', line 40

def self.run_application_bot(token, appId, channelId, messageBody)
  bot = Discordrb::Bot.new token: token, client_id: appId
  bot.send_message(channelId, messageBody)

  # Enable this Line if you want to Stream the Connection
  # bot.run
end