Class: Rubirai::Bot

Inherits:
Object
  • Object
show all
Defined in:
lib/rubirai.rb,
lib/rubirai/auth.rb,
lib/rubirai/listing.rb,
lib/rubirai/message.rb,
lib/rubirai/session.rb,
lib/rubirai/listener.rb,
lib/rubirai/multipart.rb,
lib/rubirai/event_recv.rb,
lib/rubirai/event_resp.rb,
lib/rubirai/management.rb,
lib/rubirai/plugin_info.rb

Overview

Bot represents a QQ bot at mirai side. All functions are API calls to the http plugin.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host, port = nil) ⇒ Bot

Initializes the bot

Parameters:

  • host (String)

    the host (IP or domain)

  • port (String, Integer, nil) (defaults to: nil)

    the port number (default is 80 for http)



24
25
26
27
# File 'lib/rubirai.rb', line 24

def initialize(host, port = nil)
  @base_uri = "http://#{host}#{":#{port}" if port}"
  @listener_funcs = []
end

Instance Attribute Details

#base_uriString (readonly)

Returns the base uri of mirai-api-http which the bot will send messages to.

Returns:

  • (String)

    the base uri of mirai-api-http which the bot will send messages to



18
19
20
# File 'lib/rubirai.rb', line 18

def base_uri
  @base_uri
end

#qqObject (readonly)

Returns the value of attribute qq.



18
# File 'lib/rubirai.rb', line 18

attr_reader :base_uri, :session, :qq

#sessionString (readonly)

Returns the session key.

Returns:

  • (String)

    the session key



18
# File 'lib/rubirai.rb', line 18

attr_reader :base_uri, :session, :qq

Class Method Details

.ensure_type_in(type, *types) ⇒ Object



33
34
35
36
# File 'lib/rubirai.rb', line 33

def self.ensure_type_in(type, *types)
  types = types.map { |x| x.to_s.downcase }
  type.to_s.downcase.must_be_one_of! types, RubiraiError, "not valid type: should be one of #{types}"
end

Instance Method Details

#aboutHash{String => Object}

Get Mirai API plugin information such as

{
  'version' => '1.0.0'
}

Returns:

  • (Hash{String => Object})

    plugin data



14
15
16
17
# File 'lib/rubirai/plugin_info.rb', line 14

def about
  v = call :get, '/about'
  v['data']
end

#add_listener(&listener_block) ⇒ Object



30
31
32
# File 'lib/rubirai/listener.rb', line 30

def add_listener(&listener_block)
  @listener_funcs << listener_block
end

#auth(auth_key) ⇒ String

Start authentication. Will store the session.

Parameters:

  • auth_key (String)

    the auth key defined in config file

Returns:

  • (String)

    the session key which will also be stored in the bot



8
9
10
11
# File 'lib/rubirai/auth.rb', line 8

def auth(auth_key)
  v = call :post, '/auth', json: { "authKey": auth_key }
  @session = v['session']
end

#clear_listenerObject



34
35
36
# File 'lib/rubirai/listener.rb', line 34

def clear_listener
  @listener_funcs.clear
end

#count_cached_messageInteger

Get the number of cached messages in mirai-http-api

Returns:

  • (Integer)

    the number of cached messages



64
65
66
67
68
69
# File 'lib/rubirai/event_recv.rb', line 64

def count_cached_message
  resp = call :get, '/countMessage', params: {
    sessionKey: @session
  }
  resp['data']
end

#fetch_latest_message(count = 10) ⇒ Array<Event> Also known as: fetch_latest_messages, fetch_latest_event, fetch_latest_events

Fetch count number of latest events.

Parameters:

  • count (Integer) (defaults to: 10)

    the number of events to fetch

Returns:

  • (Array<Event>)

    the event objects



21
22
23
# File 'lib/rubirai/event_recv.rb', line 21

def fetch_latest_message(count = 10)
  get_events '/fetchLatestMessage', count
end

#fetch_message(count = 10) ⇒ Array<Event> Also known as: fetch_messages, fetch_event, fetch_events

Fetch count number of oldest events.

Parameters:

  • count (Integer) (defaults to: 10)

    the number of events to fetch

Returns:

  • (Array<Event>)

    the event objects.



10
11
12
# File 'lib/rubirai/event_recv.rb', line 10

def fetch_message(count = 10)
  get_events '/fetchMessage', count
end

#friend_listArray<User>

Get friend list of the bot

Returns:

  • (Array<User>)

    list of friends



10
11
12
13
14
15
# File 'lib/rubirai/listing.rb', line 10

def friend_list
  resp = call :get, '/friendList', params: {
    sessionKey: @session
  }
  resp.map { |friend| User.new(friend, self) }
end

#gen_uri(path) ⇒ Object



29
30
31
# File 'lib/rubirai.rb', line 29

def gen_uri(path)
  URI.join(base_uri, path)
end

#get_group_config(group_id) ⇒ Object



85
86
87
88
89
90
91
# File 'lib/rubirai/management.rb', line 85

def get_group_config(group_id)
  resp = call :get, '/groupConfig', params: {
    sessionKey: @session,
    target: group_id
  }
  GroupConfig.new resp, self
end

#get_group_file_info(group_id, file_id) ⇒ Object

Get the info about a group file

Parameters:

  • group_id (Integer)

    the group id

  • file_id (String)

    the file id, e.g. /xxx-xxx-xxx-xxx



145
146
147
148
149
150
151
152
# File 'lib/rubirai/management.rb', line 145

def get_group_file_info(group_id, file_id)
  resp = call :get, '/groupFileInfo', params: {
    sessionKey: @session,
    target: group_id,
    id: file_id
  }
  GroupFile.new resp, self
end

#get_group_file_list(group_id, dir = nil) ⇒ Object



132
133
134
135
136
137
138
139
140
# File 'lib/rubirai/management.rb', line 132

def get_group_file_list(group_id, dir = nil)
  resp = call :get, '/groupFileList', params: {
    sessionKey: @session,
    target: group_id,
    dir: dir
  }.compact
  resp.must_be! Array # assert resp is Array
  resp.map { |f| GroupFileSimple.new(f, self) }
end

#get_member_info(group_id, member_id) ⇒ Object



110
111
112
113
114
115
116
117
# File 'lib/rubirai/management.rb', line 110

def get_member_info(group_id, member_id)
  resp = call :get, '/memberInfo', params: {
    sessionKey: @session,
    target: group_id,
    memberId: member_id
  }
  MemberInfo.new resp, self
end

#get_session_cfgHash{String => Object}

Get the config related to this session

Returns:

  • (Hash{String => Object})

    the config



7
8
9
10
11
# File 'lib/rubirai/session.rb', line 7

def get_session_cfg
  call :get, '/config', params: {
    sessionKey: @session
  }
end

#group_file_delete(group_id, file_id) ⇒ Object



183
184
185
186
187
188
189
190
# File 'lib/rubirai/management.rb', line 183

def group_file_delete(group_id, file_id)
  call :post, '/groupFileDelete', json: {
    sessionKey: @session,
    target: group_id,
    id: file_id
  }
  nil
end

#group_file_mv(group_id, file_id, path) ⇒ Object



173
174
175
176
177
178
179
180
181
# File 'lib/rubirai/management.rb', line 173

def group_file_mv(group_id, file_id, path)
  call :post, '/groupFileMove', json: {
    sessionKey: @session,
    target: group_id,
    id: file_id,
    movePath: path
  }
  nil
end

#group_listArray<Group>

Get group list of the bot

Returns:

  • (Array<Group>)

    list of groups



19
20
21
22
23
24
# File 'lib/rubirai/listing.rb', line 19

def group_list
  resp = call :get, '/groupList', params: {
    sessionKey: @session
  }
  resp.map { |group| Group.new(group, self) }
end

#group_mkdir(group_id, dir) ⇒ Object



164
165
166
167
168
169
170
171
# File 'lib/rubirai/management.rb', line 164

def group_mkdir(group_id, dir)
  call :post, '/groupMkdir', json: {
    sessionKey: @session,
    group: group_id,
    dir: dir
  }
  nil
end

#group_set_essence(msg_id) ⇒ Object



192
193
194
195
196
197
198
# File 'lib/rubirai/management.rb', line 192

def group_set_essence(msg_id)
  call :post, '/setEssence', json: {
    sessionKey: @session,
    target: msg_id
  }
  nil
end

#kick(group_id, member_id, msg = nil) ⇒ void

This method returns an undefined value.

Kick a member from a group

Parameters:

  • group_id (Integer)

    group id

  • member_id (Integer)

    member id

  • msg (String, nil) (defaults to: nil)

    the message for the kicked



42
43
44
45
46
47
48
49
50
51
# File 'lib/rubirai/management.rb', line 42

def kick(group_id, member_id, msg = nil)
  json = {
    sessionKey: @session,
    target: group_id,
    memberId: member_id
  }
  json[:msg] = msg if msg
  call :post, '/kick', json: json
  nil
end

#login(qq, auth_key) ⇒ void Also known as: connect

This method returns an undefined value.

Log you in.

Parameters:

  • qq (String, Integer)

    qq id

  • auth_key (String)

    the auth key set in the settings file for mirai-api-http.

See Also:



49
50
51
52
# File 'lib/rubirai/auth.rb', line 49

def (qq, auth_key)
  auth auth_key
  verify qq
end

#logoutvoid Also known as: disconnect

This method returns an undefined value.

Log you out.

See Also:



60
61
62
# File 'lib/rubirai/auth.rb', line 60

def logout
  release
end

#member_list(group_id) ⇒ Array<GroupUser>

Get member list of a group

Parameters:

  • group_id (Integer, String)

    group id

Returns:



29
30
31
32
33
34
35
# File 'lib/rubirai/listing.rb', line 29

def member_list(group_id)
  resp = call :get, '/memberList', params: {
    sessionKey: @session,
    target: group_id
  }
  resp.map { |member| GroupUser.new(member, self) }
end

#message_from_id(msg_id) ⇒ Event

Get a message event from message id

Parameters:

  • msg_id (Integer)

    message id

Returns:

  • (Event)

    the event object



54
55
56
57
58
59
60
# File 'lib/rubirai/event_recv.rb', line 54

def message_from_id(msg_id)
  resp = call :get, '/messageFromId', params: {
    sessionKey: @session,
    id: msg_id
  }
  Event.parse resp['data'], self
end

#mute(group_id, member_id, time = 0) ⇒ Object

Mute a group member

Parameters:

  • group_id (Integer)

    group id

  • member_id (Integer)

    member id

  • time (Integer) (defaults to: 0)

    the mute time



12
13
14
15
16
17
18
19
20
# File 'lib/rubirai/management.rb', line 12

def mute(group_id, member_id, time = 0)
  call :post, '/mute', json: {
    sessionKey: @session,
    target: group_id,
    memberId: member_id,
    time: time
  }
  nil
end

#mute_all(group_id) ⇒ void

This method returns an undefined value.

Mute all group

Parameters:

  • group_id (Integer)

    group id



69
70
71
72
73
74
75
# File 'lib/rubirai/management.rb', line 69

def mute_all(group_id)
  call :post, '/muteAll', json: {
    sessionKey: @session,
    target: group_id
  }
  nil
end

#peek_latest_message(count = 10) ⇒ Array<Event> Also known as: peek_latest_messages, peek_latest_event, peek_latest_events

Peek count number of latest events. (Will not delete from cache)

Parameters:

  • count (Integer) (defaults to: 10)

    the number of events to peek

Returns:

  • (Array<Event>)

    the event objects



43
44
45
# File 'lib/rubirai/event_recv.rb', line 43

def peek_latest_message(count = 10)
  get_events '/peekLatestMessage', count
end

#peek_message(count = 10) ⇒ Array<Event> Also known as: peek_messages, peek_event, peek_events

Peek count number of oldest events. (Will not delete from cache)

Parameters:

  • count (Integer) (defaults to: 10)

    the number of events to peek

Returns:

  • (Array<Event>)

    the event objects



32
33
34
# File 'lib/rubirai/event_recv.rb', line 32

def peek_message(count = 10)
  get_events '/peekMessage', count
end

#quit(group_id) ⇒ void

This method returns an undefined value.

Quit a group

Parameters:

  • group_id (Integer)

    group id



57
58
59
60
61
62
63
# File 'lib/rubirai/management.rb', line 57

def quit(group_id)
  call :post, '/quit', json: {
    sessionKey: @session,
    target: group_id
  }
  nil
end

#recall(msg_id) ⇒ Object



44
45
46
47
48
49
50
# File 'lib/rubirai/message.rb', line 44

def recall(msg_id)
  call :post, '/recall', json: {
    sessionKey: @session,
    target: msg_id
  }
  nil
end

#release(qq = nil, session = nil) ⇒ void

This method returns an undefined value.

Release a session. Only fill in the arguments when you want to control another bot on the same Mirai process.

Parameters:

  • qq (String, Integer, nil) (defaults to: nil)

    qq id. Set to nil will use the logged in bot id.

  • session (String, nil) (defaults to: nil)

    the session key. Set to nil will use the logged in credentials.

Raises:



31
32
33
34
35
36
37
38
39
40
# File 'lib/rubirai/auth.rb', line 31

def release(qq = nil, session = nil)
  qq ||= @qq
  raise RubiraiError, "not same qq: #{qq} and #{@qq}" if qq != @qq
  check qq, session

  call :post, '/release', json: { "sessionKey": @session || session, "qq": qq.to_i }
  @session = nil
  @qq = nil
  nil
end

#rename_group_file(group_id, file_id, new_name) ⇒ Object



154
155
156
157
158
159
160
161
162
# File 'lib/rubirai/management.rb', line 154

def rename_group_file(group_id, file_id, new_name)
  call :post, '/groupFileRename', json: {
    sessionKey: @session,
    target: group_id,
    id: file_id,
    rename: new_name
  }
  nil
end

#respond_to_group_invite(event_id, from_id, group_id, operation, message = '') ⇒ Object



77
78
79
80
81
82
83
84
85
86
87
# File 'lib/rubirai/event_resp.rb', line 77

def respond_to_group_invite(event_id, from_id, group_id, operation, message = '')
  call :post, '/resp/botInvitedJoinGroupRequestEvent', json: {
    sessionKey: @session,
    eventId: event_id,
    fromId: from_id,
    groupId: group_id,
    operate: operation,
    message: message
  }
  nil
end

#respond_to_member_join(event_id, from_id, group_id, operation, message = '') ⇒ void

This method returns an undefined value.

Respond to join group request (raw)

Parameters:

  • event_id (Integer)

    the event id

  • from_id (Integer)

    id of the requester

  • operation (Integer)
  • group_id (Integer)

    the group where the request is from. 0 if not from group.

  • message (String) (defaults to: '')

    the message to reply



65
66
67
68
69
70
71
72
73
74
75
# File 'lib/rubirai/event_resp.rb', line 65

def respond_to_member_join(event_id, from_id, group_id, operation, message = '')
  call :post, '/resp/memberJoinRequestEvent', json: {
    sessionKey: @session,
    eventId: event_id,
    fromId: from_id,
    groupId: group_id,
    operate: operation,
    message: message
  }
  nil
end

#respond_to_new_friend_request(event_id, from_id, operation, group_id = 0, message = '') ⇒ void

This method returns an undefined value.

Respond to new friend request (raw)

Parameters:

  • event_id (Integer)

    the event id

  • from_id (Integer)

    id of the requester

  • operation (Integer)
  • group_id (Integer) (defaults to: 0)

    the group where the request is from. 0 if not from group.

  • message (String) (defaults to: '')

    the message to reply



45
46
47
48
49
50
51
52
53
54
55
# File 'lib/rubirai/event_resp.rb', line 45

def respond_to_new_friend_request(event_id, from_id, operation, group_id = 0, message = '')
  call :post, '/resp/newFriendRequestEvent', json: {
    sessionKey: @session,
    eventId: event_id,
    fromId: from_id,
    groupId: group_id,
    operate: operation,
    message: message
  }
  nil
end

#send_friend_msg(target_qq, *msgs) ⇒ Object



36
37
38
# File 'lib/rubirai/message.rb', line 36

def send_friend_msg(target_qq, *msgs)
  send_msg :friend, target_qq, *msgs
end

#send_group_msg(target_group_id, *msgs) ⇒ Object



40
41
42
# File 'lib/rubirai/message.rb', line 40

def send_group_msg(target_group_id, *msgs)
  send_msg :group, target_group_id, *msgs
end

#send_image_msg(urls, **kwargs) ⇒ Array<String>

Send image messages

Parameters:

  • urls (Array<String>)

    the urls of the images

  • kwargs (Hash)

    keys are one of [target, qq, group].

Returns:

  • (Array<String>)

    the image ids



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/rubirai/message.rb', line 57

def send_image_msg(urls, **kwargs)
  urls.must_be! Array
  urls.each do |url|
    url.must_be! String
  end
  valid = %w[target qq group]
  res = {
    sessionKey: @session,
    urls: urls
  }
  kwargs.each do |k, v|
    res[k.to_s.downcase.to_sym] = v if valid.include? k.to_s.downcase
  end
  call :post, '/sendImageMessage', json: res
end

#send_msg(type, target_id, *msgs) ⇒ Object



25
26
27
28
29
30
31
32
33
34
# File 'lib/rubirai/message.rb', line 25

def send_msg(type, target_id, *msgs)
  self.class.ensure_type_in type, 'group', 'friend'
  chain = Rubirai::MessageChain.make(*msgs, bot: self)
  resp = call :post, "/send#{type.to_s.snake_to_camel}Message", json: {
    sessionKey: @session,
    target: target_id.to_i,
    messageChain: chain.to_a
  }
  resp['messageId']
end

#send_nudge(target_id, subject_id, kind) ⇒ Object



73
74
75
76
77
78
79
80
81
82
# File 'lib/rubirai/message.rb', line 73

def send_nudge(target_id, subject_id, kind)
  kind.to_s.downcase.must_be_one_of! %w[group friend], RubiraiError, 'kind must be one of group or friend'
  call :post, '/sendNudge', json: {
    sessionKey: @session,
    target: target_id,
    subject: subject_id,
    kind: kind.to_s.capitalize
  }
  nil
end

#send_temp_msg(target_qq, group_id, *msgs) ⇒ Integer

Send temp message

Parameters:

  • target_qq (Integer)

    target qq id

  • group_id (Integer)

    group id

  • msgs (Array<Rubirai::Message, Hash, String, Object>)

    messages to form a chain, can be any type

Returns:

  • (Integer)

    message id



14
15
16
17
18
19
20
21
22
23
# File 'lib/rubirai/message.rb', line 14

def send_temp_msg(target_qq, group_id, *msgs)
  chain = Rubirai::MessageChain.make(*msgs, bot: self)
  resp = call :post, '/sendTempMessage', json: {
    sessionKey: @session,
    qq: target_qq.to_i,
    group: group_id.to_i,
    messageChain: chain.to_a
  }
  resp['messageId']
end

#set_group_config(group_id, config) ⇒ void

This method returns an undefined value.

Set group config

Parameters:

  • group_id (Integer)

    group id

  • config (GroupConfig, Hash{String => Object})

    the configuration



98
99
100
101
102
103
104
105
106
107
108
# File 'lib/rubirai/management.rb', line 98

def set_group_config(group_id, config)
  config.must_be! [GroupConfig, Hash], RubiraiError, 'must be GroupConfig or Hash'
  config.stringify_keys! if config.is_a? Hash
  config = config.to_h if config.is_a? GroupConfig
  call :post, '/groupConfig', json: {
    sessionKey: @session,
    target: group_id,
    config: config
  }
  nil
end

#set_member_info(group_id, member_id, info) ⇒ Object



119
120
121
122
123
124
125
126
127
128
129
130
# File 'lib/rubirai/management.rb', line 119

def set_member_info(group_id, member_id, info)
  info.must_be! [MemberInfo, Hash], RubiraiError, 'must be MemberInfo or Hash'
  info.stringify_keys! if info.is_a? Hash
  info = info.to_h if info.is_a? MemberInfo
  call :post, '/memberInfo', json: {
    sessionKey: @session,
    target: group_id,
    memberId: member_id,
    info: info
  }
  nil
end

#set_session_cfg(cache_size: nil, enable_websocket: nil) ⇒ void

This method returns an undefined value.

Set the config related to this session

Parameters:

  • cache_size (Integer, nil) (defaults to: nil)

    the cache size

  • enable_websocket (Boolean, nil) (defaults to: nil)

    if to enable websocket



17
18
19
20
21
22
23
24
# File 'lib/rubirai/session.rb', line 17

def set_session_cfg(cache_size: nil, enable_websocket: nil)
  call :post, '/config', json: {
    sessionKey: @session,
    cacheSize: cache_size,
    enableWebsocket: enable_websocket
  }.compact
  nil
end

#start_listen(interval, is_blocking: false, ignore_error: false) ⇒ Object

Raises:



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/rubirai/listener.rb', line 8

def start_listen(interval, is_blocking: false, ignore_error: false)
  raise RubiraiError, 'listener is already running' if @listener&.running?
  @listener_stop_event = Concurrent::Event.new if is_blocking
  bot = self
  @listener = Concurrent::TimerTask.new(execution_interval: interval) do
    loop do
      events = fetch_message
      events.each do |e|
        @listener_funcs.each { |f| f.call e }
      rescue RuntimeError => e
        @listener_funcs.each { |f| f.call RubiraiErrorEvent.new(e, bot) unless ignore_error }
      end
      break if events.length < 10
    rescue RuntimeError => e
      @listener_funcs.each { |f| f.call RubiraiErrorEvent.new(e, bot) unless ignore_error }
      break
    end
  end
  @listener.execute
  @listener_stop_event.wait if is_blocking
end

#stop_listenObject



38
39
40
41
42
# File 'lib/rubirai/listener.rb', line 38

def stop_listen
  @listener.shutdown
  @listener_stop_event&.set
  @listener_stop_event = nil
end

#unmute(group_id, member_id) ⇒ void

This method returns an undefined value.

Unmute a group member

Parameters:

  • group_id (Integer)

    group id

  • member_id (Integer)

    member id



27
28
29
30
31
32
33
34
# File 'lib/rubirai/management.rb', line 27

def unmute(group_id, member_id)
  call :post, '/unmute', json: {
    sessionKey: @session,
    target: group_id,
    memberId: member_id
  }
  nil
end

#unmute_all(group_id) ⇒ Object



77
78
79
80
81
82
83
# File 'lib/rubirai/management.rb', line 77

def unmute_all(group_id)
  call :post, '/unmuteAll', json: {
    sessionKey: @session,
    target: group_id
  }
  nil
end

#upload_file_and_send(path_or_io, target, group_path) ⇒ String

Uploads a file to a group (currently only groups supported)

Parameters:

  • path_or_io (String, Pathname, IO)

    path to file

  • target (Integer)

    group id

  • group_path (String)

    path to file in group files

Returns:

  • (String)

    the string id of the mirai file



33
34
35
36
37
38
39
40
41
42
# File 'lib/rubirai/multipart.rb', line 33

def upload_file_and_send(path_or_io, target, group_path)
  res = call :post, '/uploadFileAndSend', form: {
    sessionKey: @session,
    type: 'Group',
    target: target,
    path: group_path,
    file: HTTP::FormData::File.new(path_or_io)
  }, headers: { content_type: 'multipart/form-data' }
  res['id']
end

#upload_image(path_or_io, type = :friend) ⇒ Hash

Uploads an image to QQ server

Returns:

  • (Hash)

    hash string keys are: { imageId, url, path }



7
8
9
10
11
12
13
14
# File 'lib/rubirai/multipart.rb', line 7

def upload_image(path_or_io, type = :friend)
  self.class.ensure_type_in type, 'friend', 'group', 'temp'
  call :post, '/uploadImage', form: {
    sessionKey: @session,
    type: type.to_s.downcase,
    img: HTTP::FormData::File.new(path_or_io)
  }, headers: { content_type: 'multipart/form-data' }
end

#upload_voice(path_or_io) ⇒ Hash

Uploads a voice file to QQ server Only group uploads available currently.

Parameters:

  • path_or_io (String, Pathname, IO)

    path to voice file

Returns:

  • (Hash)

    hash string keys are: { voiceId, url, path }



20
21
22
23
24
25
26
# File 'lib/rubirai/multipart.rb', line 20

def upload_voice(path_or_io)
  call :post, '/uploadVoice', form: {
    sessionKey: @session,
    type: 'group',
    img: HTTP::FormData::File.new(path_or_io)
  }, headers: { content_type: 'multipart/form-data' }
end

#verify(qq, session = nil) ⇒ void

This method returns an undefined value.

Verify and start a session. Also bind the session to a bot with the qq id.

Parameters:

  • qq (String, Integer)

    qq id

  • session (String, nil) (defaults to: nil)

    the session key. Set to nil will use the saved credentials.



17
18
19
20
21
22
23
24
# File 'lib/rubirai/auth.rb', line 17

def verify(qq, session = nil)
  check qq, session

  call :post, '/verify', json: { "sessionKey": @session || session, "qq": qq.to_i }
  @session = session if session
  @qq = qq
  nil
end