Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

支持推送到企业微信 #277

Merged
merged 1 commit into from
Mar 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/fir/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ def info(*args)
method_option :feishu_access_token, type: :string, desc: 'Send msg to feishu, need access_token, not whole url'
method_option :feishu_custom_message, type: :string, desc: 'add custom message to feishu'

method_option :wxwork_webhook, type: :string, desc: 'Send msg to wxwork group, need group bot webhook, whole url'
method_option :wxwork_custom_message, type: :string, desc: 'add custom message to wxwork group'
method_option :wxwork_pic_url, type: :string, desc: 'message background image, best size is 1068x455'

method_option :open, type: :boolean, desc: 'true/false if open for everyone'
method_option :password, type: :string, desc: 'Set password for app'

Expand Down
18 changes: 18 additions & 0 deletions lib/fir/util/publish.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def publish(*args, options)

dingtalk_notifier(download_url, qrcode_path)
feishu_notifier(download_url)
wxwork_notifier(download_url)

upload_mapping_file_with_publish

Expand Down Expand Up @@ -226,6 +227,23 @@ def feishu_notifier(download_url)
DefaultRest.post(url, payload)
end

def wxwork_notifier(download_url)
return if options[:wxwork_webhook].blank?
title = "#{@app_info[:name]}-#{@app_info[:version]}(Build #{@app_info[:build]})"
payload = {
"msgtype": "news",
"news": {
"articles": [{
"title": "#{title} uploaded",
"description": "#{title} uploaded at #{Time.now}\nurl: #{download_url}\n#{options[:wxwork_custom_message]}\n",
"url": download_url,
"picurl": options[:wxwork_pic_url]
}],
},
}
DefaultRest.post(options[:wxwork_webhook], payload)
end

def initialize_publish_options(args, options)
@options = options
@file_path = File.absolute_path(args.first.to_s)
Expand Down