Class: Kybus::CLI::BotDeployerTelegramConfigurator
Instance Attribute Summary collapse
Instance Method Summary
collapse
#account_id, #function_name
Constructor Details
10
11
12
13
|
# File 'lib/kybus/cli/bot/deployers/telegram_configurator.rb', line 10
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
20
21
22
23
24
25
26
27
28
|
# File 'lib/kybus/cli/bot/deployers/telegram_configurator.rb', line 20
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'] }
puts({msg: 'Making request to', url: uri, params: }.to_yaml)
res = Net::HTTP.post_form(uri, params)
puts res.body
end
|
#destroy! ⇒ Object
30
31
32
33
34
35
|
# File 'lib/kybus/cli/bot/deployers/telegram_configurator.rb', line 30
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
|