aliyun_chatbot 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +53 -0
- data/LICENSE.txt +21 -0
- data/README.md +57 -0
- data/Rakefile +6 -0
- data/aliyun_chatbot.gemspec +36 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/aliyun_chatbot.rb +14 -0
- data/lib/aliyun_chatbot/api.rb +58 -0
- data/lib/aliyun_chatbot/client.rb +61 -0
- data/lib/aliyun_chatbot/config.rb +31 -0
- data/lib/aliyun_chatbot/version.rb +3 -0
- metadata +119 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b8c30d81d5200a1823517cf7098abc965ff4757c8cf5336878e213a553bd057c
|
4
|
+
data.tar.gz: e578abb09305ec50a54614a718eb54266f8ea94cafd0e8324d3623ad8bd57560
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 819ce0cd503b2a339013b27f29f1b4efff5f96af0ca8596f4a8dbf1c9485c7d360fb84761ad35bcc1bfc017268e245f11a67389116c082ad406f6f4e9c5e382e
|
7
|
+
data.tar.gz: 1e31b57bd0adac34f246e122dbe4adc85be7cada1609d50f6dd00594298fe71c1e10dbd44a3acb7c252ee56804d29559b72843b7229fa51bda16ef1aba153ffa
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at lewislinlin@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
aliyun_chatbot (0.1.0)
|
5
|
+
http (~> 2.2)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://gems.ruby-china.com/
|
9
|
+
specs:
|
10
|
+
addressable (2.7.0)
|
11
|
+
public_suffix (>= 2.0.2, < 5.0)
|
12
|
+
diff-lcs (1.3)
|
13
|
+
domain_name (0.5.20190701)
|
14
|
+
unf (>= 0.0.5, < 1.0.0)
|
15
|
+
http (2.2.2)
|
16
|
+
addressable (~> 2.3)
|
17
|
+
http-cookie (~> 1.0)
|
18
|
+
http-form_data (~> 1.0.1)
|
19
|
+
http_parser.rb (~> 0.6.0)
|
20
|
+
http-cookie (1.0.3)
|
21
|
+
domain_name (~> 0.5)
|
22
|
+
http-form_data (1.0.3)
|
23
|
+
http_parser.rb (0.6.0)
|
24
|
+
public_suffix (4.0.1)
|
25
|
+
rake (10.5.0)
|
26
|
+
rspec (3.8.0)
|
27
|
+
rspec-core (~> 3.8.0)
|
28
|
+
rspec-expectations (~> 3.8.0)
|
29
|
+
rspec-mocks (~> 3.8.0)
|
30
|
+
rspec-core (3.8.2)
|
31
|
+
rspec-support (~> 3.8.0)
|
32
|
+
rspec-expectations (3.8.4)
|
33
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
34
|
+
rspec-support (~> 3.8.0)
|
35
|
+
rspec-mocks (3.8.1)
|
36
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
37
|
+
rspec-support (~> 3.8.0)
|
38
|
+
rspec-support (3.8.2)
|
39
|
+
unf (0.1.4)
|
40
|
+
unf_ext
|
41
|
+
unf_ext (0.0.7.6)
|
42
|
+
|
43
|
+
PLATFORMS
|
44
|
+
ruby
|
45
|
+
|
46
|
+
DEPENDENCIES
|
47
|
+
aliyun_chatbot!
|
48
|
+
bundler (~> 2.0)
|
49
|
+
rake (~> 10.0)
|
50
|
+
rspec (~> 3.0)
|
51
|
+
|
52
|
+
BUNDLED WITH
|
53
|
+
2.0.2
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 lewis
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
# AliyunChatbot
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/aliyun_chatbot`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
[ruby sdk for aliyun chatbot](https://help.aliyun.com/document_detail/60762.html?spm=a2c4g.11186623.6.593.81035929ZxOJur)
|
5
|
+
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'aliyun_chatbot'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install aliyun_chatbot
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
|
27
|
+
#config/initialize/AliyunChatbot.rb
|
28
|
+
AliyunChatbot.configure do |c|
|
29
|
+
c.ak_id = 'xx'
|
30
|
+
c.ak_secret = 'xx'
|
31
|
+
end
|
32
|
+
# rails c
|
33
|
+
client = AliyunChatbot::Client.new
|
34
|
+
|
35
|
+
|
36
|
+
# or
|
37
|
+
client = AliyunChatbot::Client.new(ak_id, ak_secret)
|
38
|
+
# instance_id from chatbot infos
|
39
|
+
client.send_message("instance_id" , "message")
|
40
|
+
|
41
|
+
```
|
42
|
+
|
43
|
+
## Development
|
44
|
+
|
45
|
+
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.
|
46
|
+
|
47
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
48
|
+
|
49
|
+
## Contributing
|
50
|
+
|
51
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/aliyun_chatbot. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
52
|
+
|
53
|
+
## License
|
54
|
+
|
55
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
56
|
+
|
57
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
lib = File.expand_path("lib", __dir__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require "aliyun_chatbot/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "aliyun_chatbot"
|
7
|
+
spec.version = AliyunChatbot::VERSION
|
8
|
+
spec.authors = ["lewis"]
|
9
|
+
spec.email = ["lewislinlin@gmail.com"]
|
10
|
+
|
11
|
+
spec.summary = %q{aliyun chatbot sdk}
|
12
|
+
spec.description = %q{aliyun chatbot sdk}
|
13
|
+
spec.homepage = "https://help.aliyun.com/document_detail/60762.html"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
17
|
+
|
18
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
19
|
+
spec.metadata["source_code_uri"] = "https://github.com/cs-cj/aliyun_chatbot"
|
20
|
+
# spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
|
21
|
+
|
22
|
+
# Specify which files should be added to the gem when it is released.
|
23
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
24
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
25
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
26
|
+
end
|
27
|
+
spec.bindir = "exe"
|
28
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
29
|
+
spec.require_paths = ["lib"]
|
30
|
+
|
31
|
+
spec.add_dependency 'http', '~> 2.2'
|
32
|
+
|
33
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
34
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
35
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
36
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "aliyun_chatbot"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require "aliyun_chatbot/version"
|
2
|
+
require 'securerandom'
|
3
|
+
require 'json'
|
4
|
+
require "http"
|
5
|
+
require 'base64'
|
6
|
+
require 'digest/md5'
|
7
|
+
require 'aliyun_chatbot/config'
|
8
|
+
require 'aliyun_chatbot/api'
|
9
|
+
require 'aliyun_chatbot/client'
|
10
|
+
|
11
|
+
module AliyunChatbot
|
12
|
+
class Error < StandardError; end
|
13
|
+
# Your code goes here...
|
14
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# Dir["#{File.dirname(__FILE__)}/api/*.rb"].each do |path|
|
2
|
+
# require path
|
3
|
+
# end
|
4
|
+
module AliyunChatbot
|
5
|
+
module Api
|
6
|
+
|
7
|
+
URL_BASE = "chatbot.cn-shanghai.aliyuncs.com"
|
8
|
+
|
9
|
+
def public_params
|
10
|
+
uuid = SecureRandom.uuid
|
11
|
+
{
|
12
|
+
Format: 'json', # String 否 返回值的类型,支持 JSON 与 XML。默认为 XML。
|
13
|
+
Version: '2017-10-11', # String 是 API 版本号,为日期形式:YYYY-MM-DD,本版本对应为2017-10-11。
|
14
|
+
AccessKeyId: ak_id, # String 是 阿里云颁发给用户的访问服务所用的密钥 ID。
|
15
|
+
# Signature String 是 签名结果串,关于签名的计算方法,请参见签名机制。
|
16
|
+
SignatureMethod: 'HMAC-SHA1', # String 是 签名方式,目前支持 HMAC-SHA1。
|
17
|
+
Timestamp: Time.now.utc.iso8601, # String 是 请求的时间戳。日期格式按照 ISO8601 标准表示,并需要使用UTC时间。格式为:YYYY-MM-DDThh:mm:ssZ,例如 2017-10-11T12:00:00Z (为北京时间 2017 年 10 月 11 日 20 点 0 分 0 秒)。
|
18
|
+
SignatureVersion: 1.0, # String 是 签名算法版本,目前版本是 1.0。
|
19
|
+
SignatureNonce: uuid #, String
|
20
|
+
}
|
21
|
+
end
|
22
|
+
# module Some
|
23
|
+
# end
|
24
|
+
|
25
|
+
def chat_params( instance_id, utterance, session_id, knowledge_id)
|
26
|
+
required = {
|
27
|
+
Action: 'Chat', # String 是 系统规定参数,取值:Chat
|
28
|
+
InstanceId: instance_id, # String 是 机器人实例ID。登录云小蜜控制台,左侧面板选择开发者->基本配置,查看机器人示例信息,可获得该实例ID。
|
29
|
+
Utterance: utterance, # String 是 机器人访问者的输入
|
30
|
+
}
|
31
|
+
|
32
|
+
# String 否
|
33
|
+
# 会话ID,用于标识一个访问者的会话和保持上下文信息。
|
34
|
+
# 对于一个新的访问者,首次调用Chat接口时无需传递此字段,机器人会开启一个会话,并在Chat接口的响应中返回该会话的SessionId。
|
35
|
+
# 对于该访问者的后续轮次的会话,调用Chat接口时传递当前会话的SessionId,机器人即可基于SessionId继续该轮次会话。
|
36
|
+
required.merge!({SessionId: session_id }) if session_id.to_s != ''
|
37
|
+
|
38
|
+
#String 否 知识库词条的关联问题的ID。若指定此ID,那么机器人会直接返回指定的关联问题的答案
|
39
|
+
required.merge!({KnowledgeId: knowledge_id }) if knowledge_id.to_s != ''
|
40
|
+
|
41
|
+
# Perspective.1 String 否 视角编码,用于调用同一知识标题下不同视角的答案。在拼装请求参数时,需要以Perspective.1={视角编码}的格式传递参数。如:&Perspective.1=FZJBY3raWr。使用SDK时以SDK中定义的参数为准。目前仅支持一个视角答案的调用。
|
42
|
+
required
|
43
|
+
end
|
44
|
+
|
45
|
+
def sender_params(sender_id, sender_nick, tag)
|
46
|
+
optional = {
|
47
|
+
|
48
|
+
}
|
49
|
+
# String 否 访问者ID。用于识别当前会话中的用户
|
50
|
+
optional.merge!({SenderId: sender_id }) if sender_id.to_s != ''
|
51
|
+
# String 否 当前会话中访问的昵称
|
52
|
+
optional.merge!({SenderNick: sender_nick }) if sender_nick.to_s != ''
|
53
|
+
# String 否 可以传递任何内容参数,该参数将会直接在返回结果中透传回来。
|
54
|
+
optional.merge!({Tag: tag }) if tag.to_s != ''
|
55
|
+
optional
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require "cgi"
|
2
|
+
module AliyunChatbot
|
3
|
+
class Client
|
4
|
+
include AliyunChatbot::Api
|
5
|
+
# include AliyunChatbot::Config
|
6
|
+
|
7
|
+
attr_accessor :ak_id, :ak_secret
|
8
|
+
|
9
|
+
def initialize ak_id = nil, ak_secret = nil
|
10
|
+
@ak_id = ak_id || AliyunChatbot.ak_id
|
11
|
+
@ak_secret = ak_secret || AliyunChatbot.ak_secret
|
12
|
+
end
|
13
|
+
|
14
|
+
def send_message instance_id, utterance, session_id = nil, knowledge_id = nil, sender_id = nil, sender_nick = nil, tag = nil
|
15
|
+
whole_params = public_params.merge chat_params(instance_id, utterance, session_id, knowledge_id)
|
16
|
+
whole_params.merge! sender_params(sender_id, sender_nick, tag)
|
17
|
+
|
18
|
+
signature = signature(whole_params)
|
19
|
+
whole_params.merge!({Signature: signature})
|
20
|
+
|
21
|
+
puts "whole_params"
|
22
|
+
puts whole_params
|
23
|
+
|
24
|
+
scheme = 'https'
|
25
|
+
url = scheme + "://" + URL_BASE + "?" + params_to_query_string(whole_params)
|
26
|
+
puts "Final Get URL : " + url
|
27
|
+
response = HTTP.get(url)
|
28
|
+
# {"SessionId"=>"xxx", "Messages"=>[{"Text"=>{"Content"=>"", "AnswerSource"=>"NO_ANSWER"}, "Type"=>"Text", "Knowledge"=>{}}], "MessageId"=>"xxx", "RequestId"=>"xxx"}
|
29
|
+
JSON.parse(response) rescue nil
|
30
|
+
end
|
31
|
+
|
32
|
+
# todo module
|
33
|
+
def params_to_query_string(params)
|
34
|
+
query = params.sort.map do |k, v|
|
35
|
+
"#{percent_cncode(k)}=#{percent_cncode(v)}" if v.to_s != ''
|
36
|
+
end.compact.join('&')
|
37
|
+
# puts "URL before sign"
|
38
|
+
# puts query
|
39
|
+
query
|
40
|
+
end
|
41
|
+
|
42
|
+
# 注意:一般支持 URL 编码的库(比如 Java 中的 java.net.URLEncoder)都是按照“application/x-www-form-urlencoded”的 MIME 类型的规则进行编码的。实现时可以直接使用这类方式进行编码,把编码后的字符串中的加号“+”替换成“%20”、星号“*”替换成“%2A”、“%7E”替换回波浪号“~”,即可得到上述规则描述的编码字符串。
|
43
|
+
def percent_cncode(str)
|
44
|
+
CGI.escape(str.to_s).gsub("+", "%20").gsub("*", "%2A").gsub("%7E", "~")
|
45
|
+
end
|
46
|
+
|
47
|
+
def signature(params)
|
48
|
+
string_to_sign = "GET" + "&" + "%2F" + "&"+ percent_cncode(params_to_query_string(params))
|
49
|
+
# puts "StringToSign"
|
50
|
+
# puts string_to_sign
|
51
|
+
signature = Base64.strict_encode64(OpenSSL::HMAC.digest('sha1', hmac_key, string_to_sign))
|
52
|
+
signature
|
53
|
+
end
|
54
|
+
|
55
|
+
def hmac_key
|
56
|
+
"#{ak_secret}&"
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module AliyunChatbot
|
2
|
+
|
3
|
+
class << self
|
4
|
+
|
5
|
+
attr_accessor :config
|
6
|
+
|
7
|
+
def configure
|
8
|
+
yield self.config ||= Config.new
|
9
|
+
config.instance_variables.each do |var_sym|
|
10
|
+
singleton_class.define_method var_sym.to_s.gsub(/^@/, '').to_sym do
|
11
|
+
config.instance_variable_get var_sym
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
class Config
|
21
|
+
attr_accessor :ak_id, :ak_secret
|
22
|
+
# config/initialize/aliyun_chatbot.rb
|
23
|
+
# AliyunChatbot.configure do |config|
|
24
|
+
# config.ak_id = ak_id from aliyun
|
25
|
+
# config.ak_secret = ak_secret from aliyun
|
26
|
+
# end
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
end
|
metadata
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: aliyun_chatbot
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- lewis
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-12-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: http
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.2'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.0'
|
69
|
+
description: aliyun chatbot sdk
|
70
|
+
email:
|
71
|
+
- lewislinlin@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".rspec"
|
78
|
+
- ".travis.yml"
|
79
|
+
- CODE_OF_CONDUCT.md
|
80
|
+
- Gemfile
|
81
|
+
- Gemfile.lock
|
82
|
+
- LICENSE.txt
|
83
|
+
- README.md
|
84
|
+
- Rakefile
|
85
|
+
- aliyun_chatbot.gemspec
|
86
|
+
- bin/console
|
87
|
+
- bin/setup
|
88
|
+
- lib/aliyun_chatbot.rb
|
89
|
+
- lib/aliyun_chatbot/api.rb
|
90
|
+
- lib/aliyun_chatbot/client.rb
|
91
|
+
- lib/aliyun_chatbot/config.rb
|
92
|
+
- lib/aliyun_chatbot/version.rb
|
93
|
+
homepage: https://help.aliyun.com/document_detail/60762.html
|
94
|
+
licenses:
|
95
|
+
- MIT
|
96
|
+
metadata:
|
97
|
+
allowed_push_host: https://rubygems.org
|
98
|
+
homepage_uri: https://help.aliyun.com/document_detail/60762.html
|
99
|
+
source_code_uri: https://github.com/cs-cj/aliyun_chatbot
|
100
|
+
post_install_message:
|
101
|
+
rdoc_options: []
|
102
|
+
require_paths:
|
103
|
+
- lib
|
104
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - ">="
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '0'
|
114
|
+
requirements: []
|
115
|
+
rubygems_version: 3.0.3
|
116
|
+
signing_key:
|
117
|
+
specification_version: 4
|
118
|
+
summary: aliyun chatbot sdk
|
119
|
+
test_files: []
|