Class: Kybus::CLI::BotDeployerTelegramConfigurator
- Inherits:
-
BotDeployerBase
- Object
- BotDeployerBase
- Kybus::CLI::BotDeployerTelegramConfigurator
- Defined in:
- lib/kybus/cli/bot/deployers/telegram_configurator.rb
Instance Attribute Summary collapse
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #create_or_update! ⇒ Object
- #destroy! ⇒ Object
-
#initialize(url, config) ⇒ BotDeployerTelegramConfigurator
constructor
A new instance of BotDeployerTelegramConfigurator.
Methods inherited from BotDeployerBase
Constructor Details
#initialize(url, config) ⇒ BotDeployerTelegramConfigurator
Returns a new instance of BotDeployerTelegramConfigurator.
11 12 13 14 |
# File 'lib/kybus/cli/bot/deployers/telegram_configurator.rb', line 11 def initialize(url, config) @url = url super(config) end |
Instance Attribute Details
#url ⇒ Object
Returns the value of attribute url.
8 9 10 |
# File 'lib/kybus/cli/bot/deployers/telegram_configurator.rb', line 8 def url @url end |
Instance Method Details
#create_or_update! ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/kybus/cli/bot/deployers/telegram_configurator.rb', line 16 def create_or_update! raise 'Missing Token' if @config['secret_token'].nil? uri = URI("https://api.telegram.org/bot#{@config['bot_token']}/setWebhook") params = { url: @url, secret_token: @config['secret_token'] } res = Net::HTTP.post_form(uri, params) puts res.body end |
#destroy! ⇒ Object
25 26 27 28 29 30 |
# File 'lib/kybus/cli/bot/deployers/telegram_configurator.rb', line 25 def destroy! uri = URI("https://api.telegram.org/bot#{@config['bot_token']}/setWebhook") params = { url: '', secret_token: '' } res = Net::HTTP.post_form(uri, params) puts res.body end |