From 3e04c175cea17517a3867c2535ed0cdc21f98573 Mon Sep 17 00:00:00 2001 From: Aaron Johnson Date: Sat, 2 Nov 2019 17:16:26 -0500 Subject: [PATCH] Fixed logging delays (missing/misplaced STDOUT.flush calls) --- commands.rb | 3 +++ run.rb | 2 ++ static_text/patchnotes.txt | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/commands.rb b/commands.rb index 75ab08f..2342720 100644 --- a/commands.rb +++ b/commands.rb @@ -35,9 +35,11 @@ def process_command_start(message, command, adm) if message_from_admin?(message, adm) msg_from_admin = true end + STDOUT.flush if is_chat_authorized?(message, @auth_chat) chat_authorized = true end + STDOUT.flush if ! msg_from_admin && ! chat_authorized if message.from.id == message.chat.id reply = reply + "\n\nWARNING: I am not authorized to work with you directly. My functionality is limited." @@ -82,6 +84,7 @@ def process_command_check(message, command, adm, simple=false) puts " Option: #{k} is #{v["loc"].to_s}" button_text = v["loc"].to_s options.insert(-1, Telegram::Bot::Types::InlineKeyboardButton.new(text: button_text, callback_data: "ZONE|#{k}")) + STDOUT.flush end message_text = "Which area would you like to check?\n" diff --git a/run.rb b/run.rb index 1a4e56e..91ceabb 100755 --- a/run.rb +++ b/run.rb @@ -354,6 +354,7 @@ def handle_message(message) reply = 'Empty String' adm = @conf['admin'] puts timestamp + ": Received command from " + "#{message.from.username}".cyan.bold + " [" + "#{message.from.id}".cyan + "]: " + "#{command}".magenta.bold + STDOUT.flush case command when '/start', '/help' process_command_start(message, command, adm) @@ -428,6 +429,7 @@ def handle_exception(e, message, notify_users) puts "PRINTING BACKTRACE...".yellow.bold puts e.backtrace puts "=" * 60 + STDOUT.flush if notify_users == true then #is this a callback query or a message case message diff --git a/static_text/patchnotes.txt b/static_text/patchnotes.txt index 4e95d30..4b1a354 100644 --- a/static_text/patchnotes.txt +++ b/static_text/patchnotes.txt @@ -3,7 +3,7 @@ Patch Notes: v1.0.01 + Added /help as an alias for /start -+ Fixed logging error due to a missing STDOUT.flush ++ Fixed logging errors related to a missing/misplaced STDOUT.flush calls v1.0.00 + Initial Release