Class: CQHttp::Api
- Inherits:
-
Object
- Object
- CQHttp::Api
- Defined in:
- lib/Bot/Api.rb
Instance Attribute Summary collapse
-
#apiUrl ⇒ Object
Returns the value of attribute apiUrl.
Class Method Summary collapse
- .acceptFriendRequest(flag, url = @apiUrl) ⇒ Object
- .acceptGroupRequest(flag, sub_type, url = @apiUrl) ⇒ Object
- .refuseFriendRequest(flag, url = @apiUrl) ⇒ Object
- .refuseGroupRequest(flag, sub_type, url = @apiUrl) ⇒ Object
- .sendGroupMessage(msg, group_id, url = @apiUrl) ⇒ Object
- .sendPrivateMessage(msg, user_id, url = @apiUrl) ⇒ Object
Instance Attribute Details
#apiUrl ⇒ Object
Returns the value of attribute apiUrl.
3 4 5 |
# File 'lib/Bot/Api.rb', line 3 def apiUrl @apiUrl end |
Class Method Details
.acceptFriendRequest(flag, url = @apiUrl) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/Bot/Api.rb', line 21 def acceptFriendRequest(flag, url=@apiUrl) ret = { flag: flag, approve: true }.to_json data = JSON.parse(Utils.httpPost("#{url}/set_friend_add_request", ret)) if data['status'] == 'ok' Utils.log Time.new, '√', '已通过好友请求' else Utils.log Time.new, '!', '请求通过失败' end end |
.acceptGroupRequest(flag, sub_type, url = @apiUrl) ⇒ Object
41 42 43 44 45 46 47 48 49 |
# File 'lib/Bot/Api.rb', line 41 def acceptGroupRequest(flag, sub_type, url=@apiUrl) ret = { flag: flag, sub_type: sub_type, approve: true }.to_json data = JSON.parse(Utils.httpPost("#{url}/set_group_add_request", ret)) if data['status'] == 'ok' Utils.log Time.new, '√', '已通过加群请求' else Utils.log Time.new, '!', '请求通过失败' end end |
.refuseFriendRequest(flag, url = @apiUrl) ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/Bot/Api.rb', line 31 def refuseFriendRequest(flag, url=@apiUrl) ret = { flag: flag, approve: false }.to_json user_id = JSON.parse(Utils.httpPost("#{url}/set_friend_add_request", ret)) if data['status'] == 'ok' Utils.log Time.new, '√', '已拒绝好友请求' else Utils.log Time.new, '!', '请求拒绝失败' end end |
.refuseGroupRequest(flag, sub_type, url = @apiUrl) ⇒ Object
51 52 53 54 55 56 57 58 59 |
# File 'lib/Bot/Api.rb', line 51 def refuseGroupRequest(flag, sub_type, url=@apiUrl) ret = { flag: flag, sub_type: sub_type, approve: false }.to_json data = JSON.parse(Utils.httpPost("#{url}/set_group_add_request", ret)) if data['status'] == 'ok' Utils.log Time.new, '√', '已拒绝加群请求' else Utils.log Time.new, '!', '请求拒绝失败' end end |
.sendGroupMessage(msg, group_id, url = @apiUrl) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/Bot/Api.rb', line 14 def sendGroupMessage(msg, group_id, url=@apiUrl) ret = { group_id: group_id, message: msg }.to_json = JSON.parse(Utils.httpPost("#{url}/send_group_msg", ret))['data']['message_id'] Utils.log Time.new, '↑', "发送至群 #{group_id} 的消息: #{msg} (#{message_id})" end |
.sendPrivateMessage(msg, user_id, url = @apiUrl) ⇒ Object
7 8 9 10 11 12 |
# File 'lib/Bot/Api.rb', line 7 def sendPrivateMessage(msg, user_id, url=@apiUrl) ret = { user_id: user_id, message: msg }.to_json = JSON.parse(Utils.httpPost("#{url}/send_private_msg", ret))['data']['message_id'] Utils.log Time.new, '↑', "发送至私聊 #{user_id} 的消息: #{msg} (#{message_id})" end |