Skip to content

Commit

Permalink
add feishu webhook support
Browse files Browse the repository at this point in the history
  • Loading branch information
jicheng1014 committed Mar 17, 2020
1 parent 7f5bb42 commit d1d1e4b
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ fir.im-cli 可以通过指令查看, 上传, iOS/Android 应用.
当然还有种解决办法是 更新 `fir-cli``2.0.5`, 这个版本换到了备用域名

# 最近更新
- (2.0.8) publish 支持 飞书通知, 可使用 `feishu_access_token``feishu_custom_message`
- (2.0.7) 修复了提示 token 错误的问题
- (2.0.6) 修复了因为文件读取方式变化而导致的文件找不到不报错的问题
- (2.0.5) 因为深信服 的黑名单误判, 将 api 切换到了备用域名
Expand Down
1 change: 1 addition & 0 deletions fir-cli.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Gem::Specification.new do |spec|
/_/ /___/_/ |_| \____/_____/___/
## 更新记录
- (2.0.8) publish 支持 飞书通知, 可使用 `feishu_access_token` 和 `feishu_custom_message`, 详情见 `fir publish --help`
- (2.0.7) 修复了提示 token 有问题的错误
- (2.0.6) 将校验文件是否存在提前
- (2.0.5) 更换了上传域名, 避免与 深信服的设备冲突
Expand Down
3 changes: 3 additions & 0 deletions lib/fir/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ def info(*args)
method_option :dingtalk_at_phones, type: :string, desc: 'at some phones, split by , eg: 13111111111,13111111112'
method_option :dingtalk_at_all, type: :boolean, default: false

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 :open, type: :boolean, desc: 'true/false if open for everyone'
method_option :password, type: :string, desc: 'Set password for app'

Expand Down
14 changes: 14 additions & 0 deletions lib/fir/util/publish.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ def publish(*args, options)
logger.info "Published succeed: #{download_url}"

qrcode_path = build_qrcode download_url

dingtalk_notifier(download_url, qrcode_path)
feishu_notifier(download_url)

upload_mapping_file_with_publish

upload_fir_cli_usage_info(received_app_info)
Expand Down Expand Up @@ -212,6 +215,17 @@ def dingtalk_notifier(download_url, qrcode_path)
logger.warn "Dingtalk send error #{e.message}"
end

def feishu_notifier(download_url)
return if options[:feishu_access_token].blank?
title = "#{@app_info[:name]}-#{@app_info[:version]}(Build #{@app_info[:build]})"
url = "https://open.feishu.cn/open-apis/bot/hook/#{options[:feishu_access_token]}"
payload = {
"title": "#{title} uploaded",
"text": "#{title} uploaded at #{Time.now}\nurl: #{download_url}\n#{options[:feishu_custom_message]}\n"
}
DefaultRest.post(url, payload)
end

def initialize_publish_options(args, options)
@options = options
@file_path = File.absolute_path(args.first.to_s)
Expand Down
2 changes: 1 addition & 1 deletion lib/fir/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# encoding: utf-8

module FIR
VERSION = '2.0.7'
VERSION = '2.0.8'
end

0 comments on commit d1d1e4b

Please sign in to comment.