cleverbot_io 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/cleverbot.rb +9 -13
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 44eeeb0cce1a6763a31117f2e1ce22c7544d69b0
|
4
|
+
data.tar.gz: 010a3e52ff6cd191a9104719a45a543dfd5a80c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf1a687301292fa6607ddf15fcc6a9ff37353453ea8f77ccafd4762f01d599bcb13a1f49bdf50018bad37e2beacf34ffe772c0e7e4a03b843291480eab3fc146
|
7
|
+
data.tar.gz: a37bf1e647a12fe59afea55ea75af16ff41940e26d35d8c4917946727358f153a426f95e3cec24a8992672dbe738fd344cd8fce3e0b2b0336c600dbcb9cadebd
|
data/CHANGELOG.md
CHANGED
data/lib/cleverbot.rb
CHANGED
@@ -2,20 +2,20 @@ require 'httpclient'
|
|
2
2
|
require 'json'
|
3
3
|
|
4
4
|
class Cleverbot
|
5
|
-
|
6
|
-
|
5
|
+
attr_reader :api_user
|
6
|
+
attr_reader :api_key
|
7
7
|
attr_accessor :nick
|
8
8
|
|
9
|
+
# Creates a new instance of the Cleverbot.
|
10
|
+
# @param api_user [String] The API user for the Cleverbot API.
|
11
|
+
# @param api_key [String] The API key for the Cleverbot API.
|
12
|
+
# @param nick [String] The reference nick. If nil, one will be set automatically through the API.
|
9
13
|
def initialize(api_user, api_key, nick = nil)
|
10
14
|
@api_user = api_user
|
11
15
|
@api_key = api_key
|
12
16
|
@nick = nick
|
13
17
|
@client = HTTPClient.new
|
14
|
-
end
|
15
18
|
|
16
|
-
# Creates a new bot instance based on the nick. If no nick has been set, this will set a random one.
|
17
|
-
# @return [Boolean] Whether the request was successful. If true, nick will be set.
|
18
|
-
def create
|
19
19
|
params = {
|
20
20
|
user: @api_user,
|
21
21
|
key: @api_key
|
@@ -23,23 +23,19 @@ class Cleverbot
|
|
23
23
|
params[:nick] = @nick unless @nick.nil?
|
24
24
|
response = JSON.parse(@client.post('https://cleverbot.io/1.0/create', params).body)
|
25
25
|
@nick = response['nick'] if response['status'] == 'success'
|
26
|
-
|
27
|
-
response['status'] == 'success'
|
28
26
|
end
|
29
27
|
|
30
28
|
# Sends the bot a message and returns its response. If the nick has not been set, it will call #{create}.
|
31
29
|
# @param str [String] The message to send to the bot.
|
32
30
|
# @return [String] The bot's response, or its error message.
|
31
|
+
# @todo Error handling.
|
33
32
|
def say(str)
|
34
33
|
params = {
|
35
34
|
user: @api_user,
|
36
35
|
key: @api_key,
|
37
|
-
text: str
|
36
|
+
text: str,
|
37
|
+
nick: @nick
|
38
38
|
}
|
39
|
-
if @nick.nil?
|
40
|
-
create
|
41
|
-
end
|
42
|
-
params[:nick] = @nick
|
43
39
|
response = JSON.parse(@client.post('https://cleverbot.io/1.0/ask', params).body)
|
44
40
|
if response['status'] == 'success'
|
45
41
|
response['response']
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cleverbot_io
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eli Foster
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-02-
|
11
|
+
date: 2016-02-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpclient
|
@@ -24,7 +24,7 @@ dependencies:
|
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 2.7.1
|
27
|
-
description: A
|
27
|
+
description: A fully featured wrapper to the Cleverbot.io web API.
|
28
28
|
email: elifosterwy@gmail.com
|
29
29
|
executables: []
|
30
30
|
extensions: []
|
@@ -32,11 +32,11 @@ extra_rdoc_files: []
|
|
32
32
|
files:
|
33
33
|
- CHANGELOG.md
|
34
34
|
- lib/cleverbot.rb
|
35
|
-
homepage: https://github.com/
|
35
|
+
homepage: https://github.com/CleverbotIO/ruby-cleverbot.io
|
36
36
|
licenses:
|
37
37
|
- CC-BY-NC-ND-4.0
|
38
38
|
metadata:
|
39
|
-
issue_tracker: https://github.com/
|
39
|
+
issue_tracker: https://github.com/CleverobtIO/ruby-cleverbot.io/issues
|
40
40
|
post_install_message:
|
41
41
|
rdoc_options: []
|
42
42
|
require_paths:
|