зеркало из
https://github.com/glebtv/telegram-bot.git
synced 2026-09-04 18:25:51 +03:00
Update rubocop, add appraisal gem
Этот коммит содержится в:
@@ -35,7 +35,7 @@ module Telegram
|
||||
def request(method, uri, query = {}, body = nil)
|
||||
res = http_request(method, uri, query.merge(token: token), body)
|
||||
status = res.status
|
||||
return JSON.parse(res.body) if 300 > status
|
||||
return JSON.parse(res.body) if status < 300
|
||||
result = JSON.parse(res.body) rescue nil # rubocop:disable RescueModifier
|
||||
err_msg = "#{res.reason}: #{result && result['info'] || '-'}"
|
||||
raise Error, err_msg
|
||||
|
||||
@@ -49,7 +49,7 @@ module Telegram
|
||||
def request(action, body = {})
|
||||
res = http_request("#{base_uri}#{action}", self.class.prepare_body(body))
|
||||
status = res.status
|
||||
return JSON.parse(res.body) if 300 > status
|
||||
return JSON.parse(res.body) if status < 300
|
||||
result = JSON.parse(res.body) rescue nil # rubocop:disable RescueModifier
|
||||
err_msg = result && result['description'] || '-'
|
||||
if result
|
||||
@@ -63,7 +63,7 @@ module Telegram
|
||||
end
|
||||
|
||||
# Splited to the sections similar to API docs.
|
||||
%w(
|
||||
%w[
|
||||
deleteWebhook
|
||||
getUpdates
|
||||
getWebhookInfo
|
||||
@@ -124,7 +124,7 @@ module Telegram
|
||||
getGameHighScores
|
||||
sendGame
|
||||
setGameScore
|
||||
).each do |method|
|
||||
].each do |method|
|
||||
define_method(method.underscore) { |*args| request(method, *args) }
|
||||
end
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ module Telegram
|
||||
|
||||
autoload :TypedUpdate, 'telegram/bot/updates_controller/typed_update'
|
||||
|
||||
PAYLOAD_TYPES = %w(
|
||||
PAYLOAD_TYPES = %w[
|
||||
message
|
||||
edited_message
|
||||
channel_post
|
||||
@@ -88,7 +88,7 @@ module Telegram
|
||||
callback_query
|
||||
shipping_query
|
||||
pre_checkout_query
|
||||
).freeze
|
||||
].freeze
|
||||
CMD_REGEX = %r{\A/([a-z\d_]{,31})(@(\S+))?(\s|$)}i
|
||||
CONFLICT_CMD_REGEX = Regexp.new("^(#{PAYLOAD_TYPES.join('|')}|\\d)")
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ module Telegram
|
||||
Instrumentation.instrument(:respond_with, type: type) { super }
|
||||
end
|
||||
|
||||
%i(answer_callback_query answer_inline_query).each do |type|
|
||||
%i[answer_callback_query answer_inline_query].each do |type|
|
||||
define_method(type) do |*args|
|
||||
Instrumentation.instrument(:respond_with, type: type) { super(*args) }
|
||||
end
|
||||
|
||||
@@ -17,7 +17,7 @@ module Telegram
|
||||
payload = event.payload
|
||||
additions = UpdatesController.log_process_action(payload)
|
||||
message = "Completed in #{event.duration.round}ms"
|
||||
message << " (#{additions.join(' | ')})" unless additions.blank?
|
||||
message << " (#{additions.join(' | ')})" if additions.present?
|
||||
message
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,7 +2,7 @@ module Telegram
|
||||
module Bot
|
||||
class UpdatesController
|
||||
module Testing
|
||||
IVARS_TO_KEEP = %i(@_session).freeze
|
||||
IVARS_TO_KEEP = %i[@_session].freeze
|
||||
|
||||
# Perform multiple dispatches on same instance.
|
||||
def dispatch_again(bot = nil, update = nil)
|
||||
|
||||
@@ -50,7 +50,7 @@ module Telegram
|
||||
end
|
||||
rescue Interrupt
|
||||
@running = false
|
||||
rescue => e
|
||||
rescue StandardError => e
|
||||
logger.error { ([e.message] + e.backtrace).join("\n") } if logger
|
||||
end
|
||||
end
|
||||
|
||||
Ссылка в новой задаче
Block a user