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/models/telegram_bot.rb

20 lines
428 B
Ruby
Raw Normal View History

2018-11-29 08:24:37 -05:00
# frozen_string_literal: true
class TelegramBot < ApplicationRecord
2018-12-06 19:41:07 -05:00
USERNAME_RE = /\A[a-z_][a-z0-9_]*\z/i.freeze
2018-11-29 08:24:37 -05:00
validates :secret, presence: true
2018-11-29 09:08:23 -05:00
validates :api_token, presence: true
2018-12-06 19:41:07 -05:00
validates :username,
allow_nil: true,
presence: true,
format: USERNAME_RE
2018-12-07 13:03:01 -05:00
def client
@client ||= api_token.try do |api_token|
Telegram::Bot::Client.new api_token
end
end
2018-11-29 08:24:37 -05:00
end