Class: RubyVibe::Bot
Overview
Set of predefined viber api requests. This class is used directly by user. Define constants for configuration settings, or add them on initialization.
Instance Attribute Summary
Attributes inherited from Client
#avatar, #name, #payload_hash, #response, #token
Instance Method Summary collapse
-
#broadcast_message(opts = {}) ⇒ Hash
Broadcast message to multiple users.
- #get_account_info ⇒ Object
- #get_online(*user_ids) ⇒ Object
- #get_user_details(user_id) ⇒ Object
-
#initialize(token: nil, name: nil, avatar: nil) ⇒ Bot
constructor
Bot object to work with.
-
#send_message(opts = {}) ⇒ Hash
Send message to user.
- #set_webhook(opts = {}) ⇒ Object
Constructor Details
#initialize(token: nil, name: nil, avatar: nil) ⇒ Bot
Returns Bot object to work with.
28 29 30 31 32 33 34 |
# File 'lib/ruby-vibe/bot.rb', line 28 def initialize(token: nil, name: nil, avatar: nil) token ||= RubyVibe::TOKEN name ||= RubyVibe::NAME avatar ||= RubyVibe::AVATAR super(token: token, name: name, avatar: avatar) end |
Instance Method Details
#broadcast_message(opts = {}) ⇒ Hash
Broadcast message to multiple users.
72 73 74 75 76 |
# File 'lib/ruby-vibe/bot.rb', line 72 def (opts = {}) opts.merge!(type: 'text') unless opts[:type] viberize(URL::BROADCAST_MESSAGE, opts) end |
#get_account_info ⇒ Object
88 89 90 |
# File 'lib/ruby-vibe/bot.rb', line 88 def get_account_info viberize(URL::GET_ACCOUNT_INFO, info: true) end |
#get_online(*user_ids) ⇒ Object
102 103 104 |
# File 'lib/ruby-vibe/bot.rb', line 102 def get_online(*user_ids) viberize(URL::GET_ONLINE, ids: Array(user_ids), info: true) end |
#get_user_details(user_id) ⇒ Object
95 96 97 |
# File 'lib/ruby-vibe/bot.rb', line 95 def get_user_details(user_id) viberize(URL::GET_USER_DETAILS, id: user_id, info: true) end |
#send_message(opts = {}) ⇒ Hash
Send message to user.
51 52 53 54 55 |
# File 'lib/ruby-vibe/bot.rb', line 51 def (opts = {}) opts.merge!(type: 'text') unless opts[:type] viberize(URL::SEND_MESSAGE, opts) end |
#set_webhook(opts = {}) ⇒ Object
81 82 83 |
# File 'lib/ruby-vibe/bot.rb', line 81 def set_webhook(opts = {}) viberize(URL::SET_WEBHOOK, opts) end |