xiaohuangji 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8d9e48c14dc58c48b19d433f3e23fb6c0f3f3448
4
+ data.tar.gz: 1d7c9c25f931b732bdb632543925cc7776c8c4db
5
+ SHA512:
6
+ metadata.gz: f2ab004ccc2f4b8998636ef0c8cf36f1cd2fa196994d979d501dcffaab6c61a954c0871d8aa9efcb97bdccfc5bf8676516f4e70e7422030374fcdf9e648b2bfd
7
+ data.tar.gz: 3030df79fc82565daa166a779f7b7c1d2d7a0b2919c9740e155114ff157c6cbf1c78c6dbb7df3fa6294fadc84f7a34ece4448b80e0f876958a442fae9f1d1122
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
- My 小黃雞
1
+ My Xiaohuangji
2
2
  ==============
3
3
 
4
- Based on [SimiSimi](http://www.simsimi.com/talk.htm?lc=zh).
4
+ Based on [SimSimi](http://www.simsimi.com/talk/Language?LC=ch).
5
5
 
6
6
  ```ruby
7
7
  require 'xiaohuangji'
data/lib/xiaohuangji.rb CHANGED
@@ -1,10 +1,10 @@
1
1
  #encoding: utf-8
2
- #Copyright (c) 2013 zhhailon <zhhailon@gmail.com>
2
+ #Copyright (c) 2013-2015 zhhailon <zhhailon@gmail.com>
3
3
 
4
- require 'xiaohuangji/simisimi'
4
+ require 'xiaohuangji/simsimi'
5
5
 
6
6
  module Xiaohuangji
7
7
  def self.chat(msg='')
8
- SimiSimi.new.chat msg
8
+ SimSimi.new.chat msg
9
9
  end
10
10
  end
@@ -0,0 +1,35 @@
1
+ #encoding: utf-8
2
+ #Copyright (c) 2013-2015 zhhailon <zhhailon@gmail.com>
3
+
4
+ require 'open-uri'
5
+ require 'json'
6
+
7
+ module Xiaohuangji
8
+ class SimSimi
9
+ def initialize
10
+ self.chat_url = 'http://www.simsimi.com/requestChat?lc=ch&ft=1.0&req=%s'
11
+ end
12
+
13
+ def chat(msg)
14
+ unless msg.nil? or msg.empty?
15
+ ans = ''
16
+ open(URI.encode(chat_url % msg)) { |f|
17
+ res = JSON.parse f.read
18
+ ans = res['res']
19
+ }
20
+ ans
21
+ else
22
+ '?'
23
+ end
24
+ end
25
+
26
+ private
27
+ def chat_url
28
+ @chat_url
29
+ end
30
+
31
+ def chat_url=(url='')
32
+ @chat_url = url
33
+ end
34
+ end
35
+ end
data/xiaohuangji.gemspec CHANGED
@@ -1,16 +1,16 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'xiaohuangji'
3
- s.version = '0.0.2'
3
+ s.version = '0.0.3'
4
4
  s.authors = ['ZHANG Hailong']
5
- s.date = '2013-01-10'
6
- s.summary = 'A chatting robot based on SimiSimi.'
7
- s.description = 'Xiaohuangji is a chatting robot based on SimiSimi.'
5
+ s.date = '2015-07-16'
6
+ s.summary = 'A chatting robot based on SimSimi.'
7
+ s.description = 'Xiaohuangji is a chatting robot based on SimSimi.'
8
8
  s.email = 'zhhailon@gmail.com'
9
9
  s.homepage = 'https://github.com/zhhailon/my-xiaohuangji'
10
10
  s.files = [
11
11
  'xiaohuangji.gemspec',
12
12
  'README.md',
13
13
  'lib/xiaohuangji.rb',
14
- 'lib/xiaohuangji/simisimi.rb'
14
+ 'lib/xiaohuangji/simsimi.rb'
15
15
  ]
16
16
  end
metadata CHANGED
@@ -1,48 +1,46 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xiaohuangji
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
5
- prerelease:
4
+ version: 0.0.3
6
5
  platform: ruby
7
6
  authors:
8
7
  - ZHANG Hailong
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-01-10 00:00:00.000000000 Z
11
+ date: 2015-07-16 00:00:00.000000000 Z
13
12
  dependencies: []
14
- description: Xiaohuangji is a chatting robot based on SimiSimi.
13
+ description: Xiaohuangji is a chatting robot based on SimSimi.
15
14
  email: zhhailon@gmail.com
16
15
  executables: []
17
16
  extensions: []
18
17
  extra_rdoc_files: []
19
18
  files:
20
- - xiaohuangji.gemspec
21
19
  - README.md
22
20
  - lib/xiaohuangji.rb
23
- - lib/xiaohuangji/simisimi.rb
21
+ - lib/xiaohuangji/simsimi.rb
22
+ - xiaohuangji.gemspec
24
23
  homepage: https://github.com/zhhailon/my-xiaohuangji
25
24
  licenses: []
25
+ metadata: {}
26
26
  post_install_message:
27
27
  rdoc_options: []
28
28
  require_paths:
29
29
  - lib
30
30
  required_ruby_version: !ruby/object:Gem::Requirement
31
- none: false
32
31
  requirements:
33
- - - ! '>='
32
+ - - ">="
34
33
  - !ruby/object:Gem::Version
35
34
  version: '0'
36
35
  required_rubygems_version: !ruby/object:Gem::Requirement
37
- none: false
38
36
  requirements:
39
- - - ! '>='
37
+ - - ">="
40
38
  - !ruby/object:Gem::Version
41
39
  version: '0'
42
40
  requirements: []
43
41
  rubyforge_project:
44
- rubygems_version: 1.8.23
42
+ rubygems_version: 2.4.5
45
43
  signing_key:
46
- specification_version: 3
47
- summary: A chatting robot based on SimiSimi.
44
+ specification_version: 4
45
+ summary: A chatting robot based on SimSimi.
48
46
  test_files: []
@@ -1,50 +0,0 @@
1
- #encoding: utf-8
2
- #Copyright (c) 2013 zhhailon <zhhailon@gmail.com>
3
-
4
- require 'open-uri'
5
- require 'json'
6
-
7
- module Xiaohuangji
8
- class SimiSimi
9
- def initialize
10
- f = open 'http://www.simsimi.com/talk.htm'
11
- self.chat_cookie = f.meta['set-cookie'].split('; ', 2)[0]
12
- self.chat_url = 'http://www.simsimi.com/func/req?lc=ch&msg=%s'
13
- end
14
-
15
- def chat(msg)
16
- unless msg.nil?
17
- f = open(URI.encode(chat_url % msg),
18
- 'Referer' => 'http://www.simsimi.com/talk.htm',
19
- 'Cookie' => chat_cookie)
20
- begin
21
- cookie = f.meta['set-cookie'].split('; ', 2)[0]
22
- self.chat_cookie = cookie
23
- rescue Exception => e
24
- $stderr.puts e
25
- end
26
- res = JSON.parse f.read
27
- res.has_key?('response') ? res['response'] : 'En?'
28
- else
29
- 'En?'
30
- end
31
- end
32
-
33
- private
34
- def chat_cookie
35
- @chat_cookie
36
- end
37
-
38
- def chat_cookie=(cookie={})
39
- @chat_cookie = cookie
40
- end
41
-
42
- def chat_url
43
- @chat_url
44
- end
45
-
46
- def chat_url=(url='')
47
- @chat_url = url
48
- end
49
- end
50
- end