ruby-cqhttp 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c58389ac3f0bf71861c81ff860e50c4b3b36dad8c6d46f8542888ae556922288
4
- data.tar.gz: af00c0a7322aefd90866849ecf28061b0c8fe9aaf9078bce7669f5a1face3a02
3
+ metadata.gz: 87e4e75d7c60595d1c8b7819e463ef23f400300735a747e6176e12ea6e7d3591
4
+ data.tar.gz: 88a63f60407888c0ba0a258ccbca71253e84492268bfd87dc193e319554c40dd
5
5
  SHA512:
6
- metadata.gz: 99cace3bf8ec77f910d22376c4ccf74784d4bb7538a06519fbd2db69acbaac0bf00daf917cd27a99ad96bc703712a1ee72150d047671eb4d95b5e24acb281f78
7
- data.tar.gz: 2c11c6eed136f57900e796740900b1dd022c18433291b4ef08dcdd7e2512e653847a2a5f7d57dbbdba64399ef70736099d1b732be0522a55326e8b968bc02d4f
6
+ metadata.gz: 9ad14175baf0305ba55f86f33446772336939fa89f3163b274906100c8d520bb9e8a51174b6e92793e4d4dc375df092bf35fa4ad27f6e9dd28f18da06c9f3249
7
+ data.tar.gz: 31f469412b075c00bb95f6ec3acb1190a20647391fba290cb06f8449669eddb570612de507a689fe1c5993f7695c8d12af5ff3771265543387ca8e5f0a5e1b8d
@@ -4,18 +4,61 @@ module CQHttp
4
4
 
5
5
  @apiUrl = 'http://127.0.0.1:5700'
6
6
  class << self
7
+ def setGroupName(group_id, group_name, url=@apiUrl)
8
+ ret = { group_id: group_id.to_i, group_name: group_name }.to_json
9
+ data = JSON.parse(Utils.httpPost("#{url}/set_group_name", ret))
10
+ if data['status'] == 'ok'
11
+ Utils.log Time.new, '√', '设置群头像成功'
12
+ else
13
+ Utils.log Time.new, '×', '设置群头像失败'
14
+ end
15
+ end
16
+
17
+ def getImage(file, url=@apiUrl) # UNFINSHED
18
+ ret = { file: file }.to_json
19
+ data = JSON.parse(Utils.httpPost("#{url}/get_image", ret))
20
+ if data['status'] == 'ok'
21
+ Utils.log Time.new, '√', '下载图片成功'
22
+ return data['data']
23
+ else
24
+ Utils.log Time.new, '×', '下载图片失败'
25
+ end
26
+ end
27
+
28
+ def get_msg(message_id, url=@apiUrl) # UNFINSHED
29
+ ret = { message_id: message_id }.to_json
30
+ data = JSON.parse(Utils.httpPost("#{url}/get_msg", ret))
31
+ if data['status'] == 'ok'
32
+ Utils.log Time.new, '√', '消息获取成功'
33
+ return data['data']
34
+ else
35
+ Utils.log Time.new, '×', '消息获取失败'
36
+ end
37
+
38
+ end
39
+
7
40
  def sendPrivateMessage(msg, user_id, url=@apiUrl)
8
41
  ret = { user_id: user_id, message: msg }.to_json
9
- message_id = JSON.parse(Utils.httpPost("#{url}/send_private_msg", ret))['data']['message_id']
10
- Utils.log Time.new, '', "发送至私聊 #{user_id} 的消息: #{msg} (#{message_id})"
11
- message_id
42
+ data = JSON.parse(Utils.httpPost("#{url}/send_private_msg", ret))
43
+ if data['status'] == 'ok'
44
+ message_id = data['data']['message_id']
45
+ Utils.log Time.new, '↑', "发送至私聊 #{user_id} 的消息: #{msg} (#{message_id})"
46
+ return message_id
47
+ else
48
+ Utils.log Time.new, '×', '发送消息失败'
49
+ end
12
50
  end
13
51
 
14
52
  def sendGroupMessage(msg, group_id, url=@apiUrl)
15
53
  ret = { group_id: group_id, message: msg }.to_json
16
- message_id = JSON.parse(Utils.httpPost("#{url}/send_group_msg", ret))['data']['message_id']
17
- Utils.log Time.new, '', "发送至群 #{group_id} 的消息: #{msg} (#{message_id})"
18
- message_id
54
+ data = JSON.parse(Utils.httpPost("#{url}/send_group_msg", ret))
55
+ if data['status'] == 'ok'
56
+ message_id = data['data']['group_id']
57
+ Utils.log Time.new, '↑', "发送至群 #{user_id} 的消息: #{msg} (#{message_id})"
58
+ return message_id
59
+ else
60
+ Utils.log Time.new, '×', '发送消息失败'
61
+ end
19
62
  end
20
63
 
21
64
  def acceptFriendRequest(flag, url=@apiUrl)
@@ -24,7 +67,7 @@ module CQHttp
24
67
  if data['status'] == 'ok'
25
68
  Utils.log Time.new, '√', '已通过好友请求'
26
69
  else
27
- Utils.log Time.new, '!', '请求通过失败'
70
+ Utils.log Time.new, '×', '请求通过失败'
28
71
  end
29
72
  end
30
73
 
@@ -34,7 +77,7 @@ module CQHttp
34
77
  if data['status'] == 'ok'
35
78
  Utils.log Time.new, '√', '已拒绝好友请求'
36
79
  else
37
- Utils.log Time.new, '!', '请求拒绝失败'
80
+ Utils.log Time.new, '×', '请求拒绝失败'
38
81
  end
39
82
  end
40
83
 
@@ -44,7 +87,7 @@ module CQHttp
44
87
  if data['status'] == 'ok'
45
88
  Utils.log Time.new, '√', '已通过加群请求'
46
89
  else
47
- Utils.log Time.new, '!', '请求通过失败'
90
+ Utils.log Time.new, '×', '请求通过失败'
48
91
  end
49
92
  end
50
93
 
@@ -54,7 +97,7 @@ module CQHttp
54
97
  if data['status'] == 'ok'
55
98
  Utils.log Time.new, '√', '已拒绝加群请求'
56
99
  else
57
- Utils.log Time.new, '!', '请求拒绝失败'
100
+ Utils.log Time.new, '×', '请求拒绝失败'
58
101
  end
59
102
  end
60
103
  end
@@ -98,7 +98,13 @@ module CQHttp
98
98
  if msg['sub_type'] == 'kick_me' # 被踢出
99
99
  Utils.log Time.at(tar.time), '!', "被 #{msg['operator_id']} 踢出群 #{msg['group_id']}"
100
100
  end
101
+ when 'group_recall'
102
+ Utils.log Time.at(tar.time), '!', "群 #{msg['group_id']} 中 #{msg['user_id']} 撤回了一条消息 (#{msg['message_id']})"
103
+ when 'friend_recall'
104
+ Utils.log Time.at(tar.time), '!', "好友 #{msg['user_id']} 撤回了一条消息 (#{msg['message_id']})"
101
105
  end
106
+ emit :notice, msg['notice_type'], msg
107
+
102
108
  #
103
109
  # 消息事件
104
110
  #
@@ -5,7 +5,8 @@ require 'event_emitter'
5
5
  require 'net/http'
6
6
 
7
7
  module CQHttp
8
- autoload :Api, File.expand_path('Bot/Api', __dir__)
9
8
  autoload :Bot, File.expand_path('Bot/Bot', __dir__)
9
+ autoload :Api, File.expand_path('Bot/Api', __dir__)
10
10
  autoload :Utils, File.expand_path('Bot/Utils', __dir__)
11
11
  end
12
+
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = 'ruby-cqhttp'
6
- s.version = '0.0.2'
6
+ s.version = '0.0.3'
7
7
  s.date = '2020-11-04'
8
8
  s.summary = 'ruby-cqhttp for osucat'
9
9
  s.description = 'ruby-cqhttp for osucat'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-cqhttp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - fantasyzhjk