lib/telegram/bot/client.rb in telegram-bot-ruby-0.3.11 vs lib/telegram/bot/client.rb in telegram-bot-ruby-0.4.0

- old
+ new

@@ -35,12 +35,13 @@ return unless response['ok'] response['result'].each do |data| update = Types::Update.new(data) @offset = update.update_id.next - log_incoming_message(update.message) - yield update.message + message = extract_message(update) + log_incoming_message(message) + yield message end rescue *TIMEOUT_EXCEPTIONS retry end @@ -48,16 +49,16 @@ def default_options { offset: 0, timeout: 20, logger: NullLogger.new } end + def extract_message(update) + update.inline_query || update.chosen_inline_result || update.message + end + def log_incoming_message(message) logger.info( - format( - 'Incoming message: text="%s" uid=%i', - message.text, - message.from.id - ) + format('Incoming message: text="%s" uid=%i', message, message.from.id) ) end end end end