15 lines
348 B
Ruby
15 lines
348 B
Ruby
|
# frozen_string_literal: true
|
||
|
|
||
|
class InitializeTelegramBot
|
||
|
include Interactor
|
||
|
|
||
|
def call
|
||
|
url = "https://api.telegram.org/bot#{context.telegram_bot.api_token}/getMe"
|
||
|
data = JSON.parse RestClient.get(url).body
|
||
|
|
||
|
context.fail! unless data['ok'] && context.telegram_bot.update(
|
||
|
username: data['result']['username'],
|
||
|
)
|
||
|
end
|
||
|
end
|