Skip to content

Commit

Permalink
Merge pull request #277 from fabcz/master
Browse files Browse the repository at this point in the history
支持推送到企业微信
  • Loading branch information
jicheng1014 authored Mar 18, 2020
2 parents d1d1e4b + a199aae commit e182bb5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
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

0 comments on commit e182bb5

Please sign in to comment.