Class: Rubychy::Bot
- Inherits:
-
Object
- Object
- Rubychy::Bot
- Defined in:
- lib/rubychy/bot.rb
Constant Summary collapse
- API_ENDPOINT =
'https://api.kik.com/v1'
Instance Attribute Summary collapse
-
#me ⇒ Object
readonly
Returns the value of attribute me.
Instance Method Summary collapse
- #config(webhook, features = Rubychy::DataTypes::Features.new) ⇒ Object
- #get_user(username) ⇒ Object
-
#initialize(username, api_token) ⇒ Bot
constructor
A new instance of Bot.
- #send_message(*messages) ⇒ Object
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
#me ⇒ Object (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 (*) msgs = { messages: sanitize('message', ) } api_post('message', msgs) end |