Class: MaxBotApi::Resources::Debugs
- Inherits:
-
Object
- Object
- MaxBotApi::Resources::Debugs
- Defined in:
- lib/max_bot_api/resources/debugs.rb
Overview
Debug helper for sending raw updates/errors to a chat.
Instance Method Summary collapse
-
#initialize(client, chat_id: 0) ⇒ Debugs
constructor
A new instance of Debugs.
-
#send(update) ⇒ Object
Send raw update debug text to the configured chat.
-
#send_err(error) ⇒ Object
Send an error message to the configured chat.
Constructor Details
#initialize(client, chat_id: 0) ⇒ Debugs
Returns a new instance of Debugs.
7 8 9 10 |
# File 'lib/max_bot_api/resources/debugs.rb', line 7 def initialize(client, chat_id: 0) @client = client @chat_id = chat_id end |
Instance Method Details
#send(update) ⇒ Object
Send raw update debug text to the configured chat.
14 15 16 17 18 19 20 21 |
# File 'lib/max_bot_api/resources/debugs.rb', line 14 def send(update) = Builders::MessageBuilder.new .set_chat(@chat_id) .set_text(update[:debug_raw].to_s) @client.request(:post, 'messages', query: { 'chat_id' => @chat_id }, body: .to_h) true end |
#send_err(error) ⇒ Object
Send an error message to the configured chat.
25 26 27 28 29 30 31 32 |
# File 'lib/max_bot_api/resources/debugs.rb', line 25 def send_err(error) = Builders::MessageBuilder.new .set_chat(@chat_id) .set_text(error.to_s) @client.request(:post, 'messages', query: { 'chat_id' => @chat_id }, body: .to_h) true end |