Class: Rubychy::Bot

Inherits:
Object
  • Object
show all
Defined in:
lib/rubychy/bot.rb

Constant Summary collapse

API_ENDPOINT =
'https://api.kik.com/v1'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(username, api_token) ⇒ Bot

Returns a new instance of Bot.



7
8
9
10
11
12
13
14
15
# File 'lib/rubychy/bot.rb', line 7

def initialize(username, api_token)
  @username = username
  @api_token = api_token
  @offset = 0
  @timeout = 60
  @fail_silently = false
  @connection = HTTPClient.new
  @connection.set_auth(nil, @username, @api_token)
end

Instance Attribute Details

#meObject (readonly)

Returns the value of attribute me.



5
6
7
# File 'lib/rubychy/bot.rb', line 5

def me
  @me
end

Instance Method Details

#config(webhook, features = Rubychy::DataTypes::Features.new) ⇒ Object



17
18
19
# File 'lib/rubychy/bot.rb', line 17

def config(webhook, features = Rubychy::DataTypes::Features.new)
  api_post('config', {webhook: webhook, features: features})
end

#get_user(username) ⇒ Object



26
27
28
29
# File 'lib/rubychy/bot.rb', line 26

def get_user(username)
  response = api_get("user/#{username}")
  Rubychy::DataTypes::User.new(response.result)
end

#send_message(*messages) ⇒ Object



21
22
23
24
# File 'lib/rubychy/bot.rb', line 21

def send_message(*messages)
  msgs = { messages: sanitize('message', messages) }
  api_post('message', msgs)
end