1
0
Fork 0
This repository has been archived on 2023-03-27. You can view files and clone it, but cannot push or open issues or pull requests.
lpr-partynest/app/interactors/initialize_telegram_bot.rb

15 lines
348 B
Ruby
Raw Normal View History

2018-12-06 20:25:38 -05:00
# 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