Class: Fabychy::Bot
- Inherits:
-
Object
- Object
- Fabychy::Bot
- Defined in:
- lib/fabychy/bot.rb
Constant Summary collapse
- API_ENDPOINT =
'https://graph.facebook.com/v2.6'
Instance Attribute Summary collapse
-
#me ⇒ Object
readonly
Returns the value of attribute me.
Instance Method Summary collapse
- #get_user(user_id) ⇒ Object
-
#initialize(token) ⇒ Bot
constructor
A new instance of Bot.
- #send_message(message) ⇒ Object
- #send_raw(message) ⇒ Object
Constructor Details
#initialize(token) ⇒ Bot
Returns a new instance of Bot.
7 8 9 10 11 12 13 |
# File 'lib/fabychy/bot.rb', line 7 def initialize(token) @access_token = token @offset = 0 @timeout = 60 @fail_silently = false @connection = HTTPClient.new end |
Instance Attribute Details
#me ⇒ Object (readonly)
Returns the value of attribute me.
5 6 7 |
# File 'lib/fabychy/bot.rb', line 5 def me @me end |
Instance Method Details
#get_user(user_id) ⇒ Object
23 24 25 26 |
# File 'lib/fabychy/bot.rb', line 23 def get_user(user_id) response = api_get("#{user_id}?fields=first_name,last_name,profile_pic,locale,timezone,gender&access_token=#{@access_token}") Fabychy::DataTypes::User.new(response.result) end |
#send_message(message) ⇒ Object
19 20 21 |
# File 'lib/fabychy/bot.rb', line 19 def () api_post("me/messages?access_token=#{@access_token}", Fabychy::Sanitizer.sanitize(:msg, )) end |
#send_raw(message) ⇒ Object
15 16 17 |
# File 'lib/fabychy/bot.rb', line 15 def send_raw() api_post("me/messages?access_token=#{@access_token}", ) end |