Class: Onebot::WebSocket::API
- Inherits:
-
Object
- Object
- Onebot::WebSocket::API
- Defined in:
- lib/Core/WebSocket/API.rb
Instance Attribute Summary collapse
-
#queueList ⇒ Object
Returns the value of attribute queueList.
Instance Method Summary collapse
- #get_msg(message_id, _url = @apiUrl) ⇒ Object
-
#initialize(ws, eventLogger) ⇒ API
constructor
A new instance of API.
-
#sendGroupMessage(message, group_id) ⇒ Hash
发送群聊消息.
-
#sendPrivateMessage(message, user_id) ⇒ Hash
发送私聊消息.
Constructor Details
#initialize(ws, eventLogger) ⇒ API
Returns a new instance of API.
7 8 9 10 11 |
# File 'lib/Core/WebSocket/API.rb', line 7 def initialize(ws, eventLogger) @ws = ws @eventLogger = eventLogger @queueList = {} end |
Instance Attribute Details
#queueList ⇒ Object
Returns the value of attribute queueList.
5 6 7 |
# File 'lib/Core/WebSocket/API.rb', line 5 def queueList @queueList end |
Instance Method Details
#get_msg(message_id, _url = @apiUrl) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/Core/WebSocket/API.rb', line 13 def get_msg(, _url = @apiUrl) ret = send('get_msg', { message_id: }) if parseRet(ret) @eventLogger.log "获取消息成功 (#{})" else @eventLogger.log "获取消息失败,错误码: #{ret.msg}, 错误消息: #{ret.wording}", Logger::WARN end ret[:data] end |
#sendGroupMessage(message, group_id) ⇒ Hash
发送群聊消息
43 44 45 46 47 48 49 50 51 |
# File 'lib/Core/WebSocket/API.rb', line 43 def sendGroupMessage(, group_id) ret = send('send_group_msg', { group_id:, message: }) if parseRet(ret) @eventLogger.log "发送至群 #{group_id} 的消息: #{} (#{ret.data.})" else @eventLogger.log "发送群消息失败,错误码: #{ret.msg}, 错误消息: #{ret.wording}", Logger::WARN end ret[:data] end |
#sendPrivateMessage(message, user_id) ⇒ Hash
发送私聊消息
28 29 30 31 32 33 34 35 36 |
# File 'lib/Core/WebSocket/API.rb', line 28 def sendPrivateMessage(, user_id) ret = send('send_private_msg', { user_id:, message: }) if parseRet(ret) @eventLogger.log "发送至私聊 #{user_id} 的消息: #{} (#{ret.data.})" else @eventLogger.log "发送私聊消息失败,错误码: #{ret.msg}, 错误消息: #{ret.wording}", Logger::WARN end ret[:data] end |