class CQHttp::Bot

消息处理,ws连接

Example:

CQHttp::Bot.connect host: host, port: port {|bot| ... }

Constants

Sender

发送人信息

@!attribute age

@return [Number] 年龄

@!attribute member_role

@return [String] 角色,owner 或 admin 或 member

@!attribute card

@return [String] 群名片/备注

@!attribute user_id

@return [Number] 发送者 QQ 号

@!attribute qqlevel

@return [String] 成员等级

@!attribute nickname

@return [String] 昵称

@!attribute title

@return [String] 专属头衔

@!attribute sex

@return [String] 性别,male 或 female 或 unknown
Target

消息事件数据

@!attribute messagetype

@return [String] 成员等级

@!attribute time

@return [Number] 事件发生的时间戳

@!attribute group_id

@return [Number] 群号

@!attribute user_id

@return [Number] 发送者 QQ 号

@!attribute message_id

@return [Number] 消息 ID

@!attribute message

@return [String] 消息内容

@!attribute raw_message

@return [String] 原始消息内容

@!attribute sub_type

@return [String] 消息子类型,私聊中如果是好友则是 friend,如果是群临时会话则是 group,群聊中正常消息是 normal,匿名消息是 anonymous,系统提示(如「管理员已禁止群内匿名聊天」)是 notice

@!attribute anonymous

@return [Hash] 匿名信息,如果不是匿名消息则为 null

Public Class Methods

connect(host:, port:) { |client| ... } click to toggle source

新建连接

@param host [String] @param port [Number] @return [WebSocket]

# File lib/Bot/Bot.rb, line 53
def self.connect(host:, port:)
  url = URI::WS.build(host: host, port: port)
  Api.setUrl()
  Utils.log '正在连接到 ' << url.to_s
  client = ::CQHttp::Bot::WebSocket.new(url)
  yield client if block_given?
  client.connect
  client
end