Class: YATelegramBot::TelegramAPI::User
- Inherits:
-
Hash
- Object
- Hash
- YATelegramBot::TelegramAPI::User
- Defined in:
- lib/ya_telegram_bot/telegram_api/user.rb
Overview
represents Telegram User
Constant Summary collapse
- FIELDS =
[:id, :first_name, :last_name, :username].freeze
Instance Method Summary collapse
-
#initialize(hash, bot = nil) ⇒ User
constructor
A new instance of User.
- #method_missing(m, *args) ⇒ Object
-
#send_photo(params = {}) ⇒ Object
uses bot to send photo to this user.
-
#send_text(params = {}) ⇒ Object
uses bot to send text to this user.
Constructor Details
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args) ⇒ Object
22 23 24 25 |
# File 'lib/ya_telegram_bot/telegram_api/user.rb', line 22 def method_missing(m, *args) return self[m] if self[m] && args.empty? super end |
Instance Method Details
#send_photo(params = {}) ⇒ Object
uses bot to send photo to this user.
44 45 46 47 48 49 |
# File 'lib/ya_telegram_bot/telegram_api/user.rb', line 44 def send_photo(params = {}) fail InitWithoutBot unless @bot params[:chat] = id @bot.send_photo params end |
#send_text(params = {}) ⇒ Object
uses bot to send text to this user.
32 33 34 35 36 37 |
# File 'lib/ya_telegram_bot/telegram_api/user.rb', line 32 def send_text(params = {}) fail InitWithoutBot unless @bot params[:chat] = id @bot.send_text params end |