Sha256: 5a56bff3895fa0722d7ed0861ab56032745757cea06a582f48e364f0460f2c58

Contents?: true

Size: 1.1 KB

Versions: 1

Compression:

Stored size: 1.1 KB

Contents

require 'telegram/bot/config_methods'

module Telegram
  extend Bot::ConfigMethods

  module Bot
    class Error < StandardError; end
    class NotFound < Error; end

    # Error class for events when chat is not available anymore for bot.
    # While Telegram has same error codes for different messages and there is no
    # official docs for this error codes it uses `description` to
    # check response.
    class StaleChat < Error
      DESCRIPTIONS = [
        'bot was kicked',
        "can't write to",
        'group chat is deactivated',
      ].freeze

      class << self
        def match_response?(response)
          description = response['description'].to_s
          DESCRIPTIONS.any? { |x| description[x] }
        end
      end
    end

    autoload :Client,             'telegram/bot/client'
    autoload :ClientStub,         'telegram/bot/client_stub'
    autoload :Middleware,         'telegram/bot/middleware'
    autoload :UpdatesController,  'telegram/bot/updates_controller'
    autoload :UpdatesPoller,      'telegram/bot/updates_poller'
  end
end

require 'telegram/bot/railtie' if defined?(Rails)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
telegram-bot-0.6.0 lib/telegram/bot.rb