dingtalk-cli 0.0.6 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 17d2d43e75a06493a7eb51e56e540cc73c6db31ddd2b4cdee60677b15fdec0c1
4
- data.tar.gz: 98f136d8f3f729059bffa2022eaeafdacad45b9e5317427787e1665478419a3e
3
+ metadata.gz: b960d9621c524056cffedb31ee131e532843719c7e115c9a52e7ae661b7fdb75
4
+ data.tar.gz: 367bac3d8d3878b47cfcb5141fcc56af442a52b8ef9a1b7b117f0649d149bb45
5
5
  SHA512:
6
- metadata.gz: 10502a20afd65b6738bc1e6550c0051d69c0e521b277c68114e6331cad796fcd443f56b67edafe2210377f05e3cbf9b60b08c35a273b655d70528f5c2cf8de8b
7
- data.tar.gz: 867fdf91173294c773fd6e6a15b6931ad671749b1548b6cdde4ee64bb651b51cac7dd6a3a87a5bae6b46320367fd2499bc3c0a460f0d95d2354895eaaa9706cf
6
+ metadata.gz: 3424337d008f18df7ec5890c3657e31183655eb89d273efc3d1104580e9e8835e9f8232113ebbb33b0af8e39d292e749d07e6c1989301d3fb1e0eacb1814b342
7
+ data.tar.gz: 55a5a30e1d01022f3bc15bd45f3b85dec0b0fe27729fc4ba2088ca7c4d2185b1ae53ddd09c76d27d4e7405022640d63dff267b500444428a07359c78dfbf5042
data/README.md CHANGED
@@ -40,9 +40,9 @@ Commands:
40
40
 
41
41
  + action-card 发送整体跳转ActionCard类型消息
42
42
  + feed-card 发送FeedCard类型消息
43
- + link 发送link类型消息
44
- + markdown 发送link类型消息
45
- + text 发送text类型消息
43
+ + link 发送Link类型消息
44
+ + markdown 发送Markdown类型消息
45
+ + text 发送Text类型消息
46
46
 
47
47
  Options:
48
48
 
@@ -69,6 +69,17 @@ source ~/.bash_profile
69
69
  ```
70
70
 
71
71
  > 说明:配置的优先级为:参数配置 > 临时环境变量配置 > 全局环境变量配置
72
+ ## 功能列表
73
+
74
+ - [x] 发送消息类型:Text
75
+ - [x] 发送消息类型:Markdown
76
+ - [x] 发送消息类型:Link
77
+ - [x] 发送消息类型:FeedCard
78
+ - [x] 发送消息类型:ActionCard
79
+ - [x] 安全设置:自定义关键词
80
+ - [x] 安全设置:加签
81
+ - [x] 安全设置:IP地址(段)
82
+
72
83
  ## 开发
73
84
 
74
85
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -8,7 +8,7 @@ module DingTalk
8
8
  self.summary = '发送整体跳转ActionCard类型消息'
9
9
 
10
10
  self.description = <<-DESC
11
- 发送text类型消息,消息内容为`CONTENT`
11
+ 发送ActionCard类型消息,消息内容为`CONTENT`
12
12
  DESC
13
13
 
14
14
  self.arguments = [
@@ -8,7 +8,7 @@ module DingTalk
8
8
  self.summary = '发送FeedCard类型消息'
9
9
 
10
10
  self.description = <<-DESC
11
- 发送text类型消息,消息内容为`LINK Array JSON`,格式:`[{ "title": "xxx", "pic": "https://xxx.com/icon.png", "link": "https://xxx.com/" }]`
11
+ 发送FeedCard类型消息,消息内容为`LINK Array JSON`,格式:`[{ "title": "xxx", "pic": "https://xxx.com/icon.png", "link": "https://xxx.com/" }]`
12
12
  DESC
13
13
 
14
14
  self.arguments = [
@@ -5,10 +5,10 @@ require_relative '../utils/http_helper'
5
5
  module DingTalk
6
6
  class Command
7
7
  class Link < Command
8
- self.summary = '发送link类型消息'
8
+ self.summary = '发送Link类型消息'
9
9
 
10
10
  self.description = <<-DESC
11
- 发送text类型消息,消息内容为`CONTENT`
11
+ 发送Link类型消息,消息内容为`CONTENT`
12
12
  DESC
13
13
 
14
14
  self.arguments = [
@@ -5,10 +5,10 @@ require_relative '../utils/http_helper'
5
5
  module DingTalk
6
6
  class Command
7
7
  class Markdown < Command
8
- self.summary = '发送link类型消息'
8
+ self.summary = '发送Markdown类型消息'
9
9
 
10
10
  self.description = <<-DESC
11
- 发送text类型消息,消息内容为`CONTENT`
11
+ 发送Markdown类型消息,消息内容为`CONTENT`
12
12
  DESC
13
13
 
14
14
  self.arguments = [
@@ -5,10 +5,10 @@ require_relative '../utils/http_helper'
5
5
  module DingTalk
6
6
  class Command
7
7
  class Text < Command
8
- self.summary = '发送text类型消息'
8
+ self.summary = '发送Text类型消息'
9
9
 
10
10
  self.description = <<-DESC
11
- 发送text类型消息,消息内容为`CONTENT`
11
+ 发送Text类型消息,消息内容为`CONTENT`
12
12
  DESC
13
13
 
14
14
  self.arguments = [
@@ -1,5 +1,9 @@
1
1
  require 'faraday';
2
2
  require 'faraday_middleware'
3
+ require 'uri'
4
+ require 'json'
5
+ require 'base64'
6
+ require 'openssl'
3
7
 
4
8
  require_relative '../core/text'
5
9
  require_relative '../core/link'
@@ -15,31 +19,23 @@ module DingTalk
15
19
  access_token = token || ENV['DINGTALK_TOKEN']
16
20
  access_secret = token || ENV['DINGTALK_SECRET']
17
21
  return 'A message access token is required.' unless access_token
18
- if access_secret then
19
- timestamp = "#{ Time.now.to_i * 1000 }\n#{ access_secret }"
20
-
21
-
22
-
23
- # Long timestamp = System.currentTimeMillis();
24
- # String stringToSign = timestamp + "\n" + secret;
25
- # Mac mac = Mac.getInstance("HmacSHA256");
26
- # mac.init(new SecretKeySpec(secret.getBytes("UTF-8"), "HmacSHA256"));
27
- # byte[] signData = mac.doFinal(stringToSign.getBytes("UTF-8"));
28
- # return URLEncoder.encode(new String(Base64.encodeBase64(signData)),"UTF-8");
29
-
30
-
31
-
32
-
22
+ if access_secret.nil? || access_secret.empty? then
23
+ uri = URI.parse("#{ DINGTALK_URL }?access_token=#{ access_token }")
24
+ else
25
+ timestamp = "#{(Time.now.to_f * 1000).to_i}"
26
+ content = "#{timestamp}\n#{access_secret}".encode("utf-8")
27
+ hash = OpenSSL::HMAC.digest('sha256', access_secret, content)
28
+ sign = Base64.strict_encode64(hash)
29
+ uri = URI.parse("#{ DINGTALK_URL }?access_token=#{ access_token }&timestamp=#{ timestamp }&sign=#{ sign }")
33
30
  end
34
- url = "#{ DINGTALK_URL }?access_token=#{ access_token }"
35
31
  http_client = Faraday.new() do |builder|
36
32
  builder.request :url_encoded
37
33
  builder.request :json
38
34
  builder.response :logger
39
35
  builder.adapter :net_http
40
36
  end
41
- res = http_client.post url, params.to_json, 'Content-Type' => 'application/json'
42
- res.body
37
+ res = http_client.post uri, params.to_json, 'Content-Type' => 'application/json'
38
+ JSON::pretty_generate(JSON(res.body))
43
39
  end
44
40
 
45
41
  def self.send_text(content, at_mobiles = [], is_at_all = false, token = nil, secret = nil)
@@ -1,3 +1,3 @@
1
1
  module DingTalk
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dingtalk-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - 大龙侠
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-13 00:00:00.000000000 Z
11
+ date: 2020-05-19 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: 自定义钉钉群机器人 dingtalk-cli
14
14
  email: