qqbot 0.1.3 → 0.1.4

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
  SHA1:
3
- metadata.gz: 120c4aa4866795fed2cfc1c6476f7b076226fd9e
4
- data.tar.gz: 17f01626a72c61cffa44b73a4f895c4cab260abd
3
+ metadata.gz: 69a4f2e3253445c00a18189021bf1dfa15e4ad28
4
+ data.tar.gz: 3a7deb70021127a9a28abf29e20c1c78fee1f30b
5
5
  SHA512:
6
- metadata.gz: ae281bf043ecfde82874e28a1d9f4c3ca7db950bd42a583d67e698b2ca3194203d1d954fb13e0429455808d65ff7bcd21563ba09f652641bba17a5d9632e89b4
7
- data.tar.gz: 8be5586fe6d08a483436a5724ed7813ebf024bfb40330cc798da55403bbbce248173c95a8e3800936a6aac2a56026b84f9cbc9ee80ece942198517de74312635
6
+ metadata.gz: 70e394857f4eb1b160bdbb7bad205743d49b604d79cba7381eeff9e51e26ee35e2bad3382d365e1c33ff084468adb65d97cb131e28b6419573d9251cd937edbe
7
+ data.tar.gz: 05d3af56835a3849214bce437d80eeb5df8aee6b3c445404c61de39602b86cff4449b99dbda7fe31888c2ff6485821400558baa92f5c8bdc95bdef4b05ef9c0c
data/README.md CHANGED
@@ -31,10 +31,22 @@ end
31
31
  ### 示例代码
32
32
 
33
33
  [在控制台打印接收到的所有消息][1]
34
- [通过 Tuling123 的 Api 实现自动回复功能][2]
34
+
35
+ 效果:
36
+
37
+ ![Console][2]
38
+
39
+ [通过 Tuling123 的 Api 实现自动回复功能][3]
40
+
41
+ 效果:
42
+
43
+ ![Tuling][4]
44
+
35
45
 
36
46
  [1]: https://gist.github.com/ScienJus/f1ba1e5b1611cca662cc
37
- [2]: https://gist.github.com/ScienJus/26a341fda25d009acea1
47
+ [2]: http://www.scienjus.com/wp-content/uploads/2015/12/console.png
48
+ [3]: https://gist.github.com/ScienJus/26a341fda25d009acea1
49
+ [4]: http://www.scienjus.com/wp-content/uploads/2015/12/tuling.jpg
38
50
 
39
51
  ### Api 列表
40
52
 
@@ -30,7 +30,7 @@ module QQBot
30
30
  autoload :Discuss, 'qqbot/model'
31
31
  autoload :Message, 'qqbot/model'
32
32
  autoload :Font, 'qqbot/model'
33
- autoload :AccountInfo, 'qqbot/model'
33
+ autoload :UserInfo, 'qqbot/model'
34
34
  autoload :Birthday, 'qqbot/model'
35
35
  autoload :Recent, 'qqbot/model'
36
36
  autoload :Online, 'qqbot/model'
@@ -273,6 +273,19 @@ module QQBot
273
273
  @client.get(uri, 'http://d1.web2.qq.com/proxy.html?v=20151105001&callback=1&id=2')
274
274
  end
275
275
 
276
+ def get_friend_info(friend_id)
277
+ uri = URI('http://s.web2.qq.com/api/get_friend_info2')
278
+ uri.query =
279
+ URI.encode_www_form(
280
+ tuin: friend_id,
281
+ vfwebqq: @options[:vfwebqq],
282
+ clientid: QQBot::CLIENT_ID,
283
+ psessionid: @options[:psessionid],
284
+ t: 0.1
285
+ )
286
+ @client.get(uri, 'http://s.web2.qq.com/proxy.html?v=20130916001&callback=1&id=1')
287
+ end
288
+
276
289
  def hash
277
290
  self.class.hash(@options[:uin], @options[:ptwebqq])
278
291
  end
@@ -13,10 +13,10 @@ module QQBot
13
13
  if json['retcode'] == 0
14
14
  return json['result']
15
15
  else
16
- QQBot::LOGGER.info "请求失败, JSON返回码 #{json['retcode']}"
16
+ QQBot::LOGGER.info "请求失败,JSON返回码 #{json['retcode']}"
17
17
  end
18
18
  else
19
- QQBot::LOGGER.info "请求失败,HTTP返回码#{code} retcode"
19
+ QQBot::LOGGER.info "请求失败,HTTP返回码 #{code}"
20
20
  end
21
21
  end
22
22
 
@@ -27,10 +27,10 @@ module QQBot
27
27
  QQBot::LOGGER.info '发送成功'
28
28
  return true
29
29
  else
30
- QQBot::LOGGER.info "发送失败 返回码 #{json['retcode']}"
30
+ QQBot::LOGGER.info "发送失败,JSON返回码 #{json['retcode']}"
31
31
  end
32
32
  else
33
- QQBot::LOGGER.info "请求失败,返回码 #{code}"
33
+ QQBot::LOGGER.info "请求失败,HTTP返回码 #{code}"
34
34
  end
35
35
  end
36
36
 
@@ -318,35 +318,49 @@ module QQBot
318
318
 
319
319
  if result
320
320
  # TODO
321
- account_info = QQBot::AccountInfo.new
322
- account_info.phone = result['phone']
323
- account_info.occupation = result['occupation']
324
- account_info.college = result['college']
325
- account_info.id = result['uin']
326
- account_info.blood = result['blood']
327
- account_info.slogan = result['lnick']
328
- account_info.homepage = result['homepage']
329
- account_info.vip_info = result['vip_info']
330
- account_info.city = result['city']
331
- account_info.country = result['country']
332
- account_info.province = result['province']
333
- account_info.personal = result['personal']
334
- account_info.shengxiao = result['shengxiao']
335
- account_info.nickname = result['nick']
336
- account_info.email = result['email']
337
- account_info.account = result['account']
338
- account_info.gender = result['gender']
339
- account_info.mobile = result['mobile']
340
- birthday = QQBot::Birthday.new
341
- birthday.year = result['birthday']['year']
342
- birthday.month = result['birthday']['month']
343
- birthday.day = result['birthday']['day']
344
- account_info.birthday = birthday
345
-
346
- account_info
321
+ build_user_info(result)
347
322
  end
348
323
  end
349
324
 
325
+ def get_friend_info(friend_id)
326
+ code, body = @api.get_friend_info(friend_id)
327
+ result = self.class.check_response_json(code, body)
328
+
329
+ if result
330
+ # TODO
331
+ build_user_info(result)
332
+ end
333
+ end
334
+
335
+ def build_user_info(result)
336
+ user_info = QQBot::UserInfo.new
337
+ user_info.phone = result['phone']
338
+ user_info.occupation = result['occupation']
339
+ user_info.college = result['college']
340
+ user_info.id = result['uin']
341
+ user_info.blood = result['blood']
342
+ user_info.slogan = result['lnick']
343
+ user_info.homepage = result['homepage']
344
+ user_info.vip_info = result['vip_info']
345
+ user_info.city = result['city']
346
+ user_info.country = result['country']
347
+ user_info.province = result['province']
348
+ user_info.personal = result['personal']
349
+ user_info.shengxiao = result['shengxiao']
350
+ user_info.nickname = result['nick']
351
+ user_info.email = result['email']
352
+ user_info.account = result['account']
353
+ user_info.gender = result['gender']
354
+ user_info.mobile = result['mobile']
355
+ birthday = QQBot::Birthday.new
356
+ birthday.year = result['birthday']['year']
357
+ birthday.month = result['birthday']['month']
358
+ birthday.day = result['birthday']['day']
359
+ user_info.birthday = birthday
360
+
361
+ user_info
362
+ end
363
+
350
364
  def get_recent_list
351
365
  code, body = @api.get_recent_list
352
366
  result = self.class.check_response_json(code, body)
@@ -23,7 +23,7 @@ module QQBot
23
23
  attr_accessor :color, :name, :size, :style
24
24
  end
25
25
 
26
- class AccountInfo
26
+ class UserInfo
27
27
  attr_accessor :phone, :occupation, :college, :id, :blood, :slogan, :homepage, :vip_info, :city, :country, :province, :personal, :shengxiao, :nickname, :email, :account, :gender, :mobile, :birthday
28
28
  end
29
29
 
@@ -1,3 +1,3 @@
1
1
  module QQBot
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
@@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["ScienJus"]
10
10
  spec.email = ["i@scienjus.com"]
11
11
 
12
- spec.summary = %q{a qq bot based on smart qq(web qq).}
13
- spec.description = %q{a qq bot based on smart qq api.}
12
+ spec.summary = %q{a qq robot based on smart qq api.}
13
+ spec.description = %q{a qq robot based on smart qq api.}
14
14
  spec.homepage = "https://github.com/ScienJus/qqbot"
15
15
  spec.license = "MIT"
16
16
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qqbot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - ScienJus
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-12-30 00:00:00.000000000 Z
11
+ date: 2016-01-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,7 +52,7 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.0'
55
- description: a qq bot based on smart qq api.
55
+ description: a qq robot based on smart qq api.
56
56
  email:
57
57
  - i@scienjus.com
58
58
  executables: []
@@ -102,5 +102,5 @@ rubyforge_project:
102
102
  rubygems_version: 2.4.5.1
103
103
  signing_key:
104
104
  specification_version: 4
105
- summary: a qq bot based on smart qq(web qq).
105
+ summary: a qq robot based on smart qq api.
106
106
  test_files: []