From c3ae39c312a67602ac8a2d74b5ad7697ede83613 Mon Sep 17 00:00:00 2001 From: Aaron Johnson Date: Sat, 2 Nov 2019 16:45:07 -0500 Subject: [PATCH 1/7] Added a STDOUT.flush for /report --- commands.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/commands.rb b/commands.rb index 5552dd1..45399f9 100644 --- a/commands.rb +++ b/commands.rb @@ -112,6 +112,7 @@ def process_command_report(message, command, adm, simple=false) send_message(message.chat.id,report) #delete_message(confirmation) #delete_confirmation(confirmation) + STDOUT.flush else send_message(message.chat.id,"I am not authorized to provide this information here.") end From 674c96be0b0f96227ef9155758f12e750fa0035e Mon Sep 17 00:00:00 2001 From: Aaron Johnson Date: Sat, 2 Nov 2019 16:51:51 -0500 Subject: [PATCH 2/7] Added /help as an alias for /start --- commands.rb | 2 +- run.rb | 2 +- static_text/patchnotes.txt | 6 +++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/commands.rb b/commands.rb index 45399f9..3f286a8 100644 --- a/commands.rb +++ b/commands.rb @@ -28,7 +28,7 @@ end def process_command_start(message, command, adm) reply = "I am #{@botname}, and I am here to provide temperature information from various sensors. Currently I can retrieve information " + "from temperature sensors. In a future version, I will also report when temperatures are out of a specified range through regular checks.\n\n" + - "Commands available:\n/start (Shows this message)\n/check or /c (Show a specific temperature interactively)\n/report or /r (Show all temperatures)\n" + + "Commands available:\n/start or /help (Shows this message)\n/check or /c (Show a specific temperature interactively)\n/report or /r (Show all temperatures)\n" + "/simple or /s (Show a simplified report)\n\nExtra functions:\n/whoami or /chatinfo (Provides IDs for internal use)\n/whereareyou or /location (Provides hostname for bot server)\n\n" + "Check again later to see if any new functions have been added, or use /patchnotes to learn about recent updates.\n" + "You can also view the source code at the following location:\nhttps://git.skyfall.tech/skyfall/heatbot" diff --git a/run.rb b/run.rb index fa6c463..a04da47 100755 --- a/run.rb +++ b/run.rb @@ -353,7 +353,7 @@ def handle_message(message) adm = @conf['admin'] puts timestamp + ": Received command from " + "#{message.from.username}".cyan.bold + " [" + "#{message.from.id}".cyan + "]: " + "#{command}".magenta.bold case command - when '/start' + when '/start', '/help' process_command_start(message, command, adm) when '/patch', '/patchnotes', '/version', '/versioninfo' process_command_patchnotes(message, command, adm) diff --git a/static_text/patchnotes.txt b/static_text/patchnotes.txt index 0b43997..4e95d30 100644 --- a/static_text/patchnotes.txt +++ b/static_text/patchnotes.txt @@ -1,5 +1,9 @@ SkyfallTech HeatBot Patch Notes: -v0.1.00 +v1.0.01 ++ Added /help as an alias for /start ++ Fixed logging error due to a missing STDOUT.flush + +v1.0.00 + Initial Release From 444795fd9de0568ed1593124da2c323f7c5479a0 Mon Sep 17 00:00:00 2001 From: Aaron Johnson Date: Sat, 2 Nov 2019 17:10:15 -0500 Subject: [PATCH 3/7] Fixed sent message logging (STDOUT.flush moved in send_message) --- commands.rb | 1 - run.rb | 4 +++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/commands.rb b/commands.rb index 3f286a8..75ab08f 100644 --- a/commands.rb +++ b/commands.rb @@ -112,7 +112,6 @@ def process_command_report(message, command, adm, simple=false) send_message(message.chat.id,report) #delete_message(confirmation) #delete_confirmation(confirmation) - STDOUT.flush else send_message(message.chat.id,"I am not authorized to provide this information here.") end diff --git a/run.rb b/run.rb index a04da47..1a4e56e 100755 --- a/run.rb +++ b/run.rb @@ -287,18 +287,20 @@ def send_message(chatid, message_text, imageurl = nil) if imageurl != nil #Send message with text as html link to image message = Telegram::Bot::Client.run(@token) {|bot| message = bot.api.send_message(chat_id: chatid, text: "#{message_text}.", parse_mode: "HTML") } + puts timestamp + ": Sent: #{message_text.inspect}\n\n" + STDOUT.flush #puts timestamp + ": Sent: #{message_text.inspect}\n\n" return message else #Send a plain-text message message = Telegram::Bot::Client.run(@token) {|bot| bot.api.send_message(chat_id: chatid, text: message_text) } puts timestamp + ": Sent: #{message_text.inspect}\n\n" + STDOUT.flush #puts message #message = message["results"] #puts message return message end - STDOUT.flush end def send_message_markdown(chatid, message_text) From 3e04c175cea17517a3867c2535ed0cdc21f98573 Mon Sep 17 00:00:00 2001 From: Aaron Johnson Date: Sat, 2 Nov 2019 17:16:26 -0500 Subject: [PATCH 4/7] 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 From ab3b22428e08b53b38853bc31643bf9810badd8e Mon Sep 17 00:00:00 2001 From: Aaron Johnson Date: Sat, 2 Nov 2019 17:18:07 -0500 Subject: [PATCH 5/7] Fixed logging delays (missing/misplaced STDOUT.flush calls) --- static_text/patchnotes.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static_text/patchnotes.txt b/static_text/patchnotes.txt index 4b1a354..3c7336e 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 errors related to a missing/misplaced STDOUT.flush calls ++ Fixed logging delays related to a missing/misplaced STDOUT.flush calls v1.0.00 + Initial Release From 87350cc890ab42b36230fcb1e76ef53145f0ab5f Mon Sep 17 00:00:00 2001 From: Aaron Johnson Date: Fri, 29 Nov 2019 20:54:40 -0600 Subject: [PATCH 6/7] Implemented two-part sent message logging --- run.rb | 18 +++++++++++++++--- static_text/patchnotes.txt | 3 +++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/run.rb b/run.rb index 91ceabb..8b433fa 100755 --- a/run.rb +++ b/run.rb @@ -286,15 +286,23 @@ end def send_message(chatid, message_text, imageurl = nil) if imageurl != nil #Send message with text as html link to image + print timestamp + ": Sending ............ " message = Telegram::Bot::Client.run(@token) {|bot| message = bot.api.send_message(chat_id: chatid, text: "#{message_text}.", parse_mode: "HTML") } - puts timestamp + ": Sent: #{message_text.inspect}\n\n" + STDOUT.flush + print "OK\n".green.bold + STDOUT.flush + puts "Sent: #{message_text.inspect}\n\n" STDOUT.flush #puts timestamp + ": Sent: #{message_text.inspect}\n\n" return message else #Send a plain-text message + print timestamp + ": Sending ............ " message = Telegram::Bot::Client.run(@token) {|bot| bot.api.send_message(chat_id: chatid, text: message_text) } - puts timestamp + ": Sent: #{message_text.inspect}\n\n" + STDOUT.flush + print "OK\n".green.bold + STDOUT.flush + puts "Sent: #{message_text.inspect}\n\n" STDOUT.flush #puts message #message = message["results"] @@ -305,8 +313,12 @@ end def send_message_markdown(chatid, message_text) #Send a plain-text message + print timestamp + ": Sending ............ " + STDOUT.flush Telegram::Bot::Client.run(@token) {|bot| bot.api.send_message(chat_id: chatid, text: "```#{message_text}```", parse_mode: 'Markdown') } - puts timestamp + ": Sent: #{message_text.inspect}\n\n" + print "OK\n".green.bold + STDOUT.flush + puts "Sent: #{message_text.inspect}\n\n" STDOUT.flush end diff --git a/static_text/patchnotes.txt b/static_text/patchnotes.txt index 3c7336e..fe7ea18 100644 --- a/static_text/patchnotes.txt +++ b/static_text/patchnotes.txt @@ -1,6 +1,9 @@ SkyfallTech HeatBot Patch Notes: +v1.0.02 ++ Implemented two-part sent message logging (affects server only) + v1.0.01 + Added /help as an alias for /start + Fixed logging delays related to a missing/misplaced STDOUT.flush calls From c370134cc68d8a7c9f57d9ef1f8d144fdb2f08b5 Mon Sep 17 00:00:00 2001 From: Aaron Johnson Date: Fri, 29 Nov 2019 20:59:19 -0600 Subject: [PATCH 7/7] Added /help command to patch notes --- static_text/patchnotes.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/static_text/patchnotes.txt b/static_text/patchnotes.txt index fe7ea18..3926922 100644 --- a/static_text/patchnotes.txt +++ b/static_text/patchnotes.txt @@ -3,6 +3,7 @@ Patch Notes: v1.0.02 + Implemented two-part sent message logging (affects server only) ++ Added /help command (same as /start) v1.0.01 + Added /help as an alias for /start