diff --git a/commands.rb b/commands.rb index 5552dd1..2342720 100644 --- a/commands.rb +++ b/commands.rb @@ -28,16 +28,18 @@ 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" 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 fa6c463..91ceabb 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) @@ -352,8 +354,9 @@ 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' + when '/start', '/help' process_command_start(message, command, adm) when '/patch', '/patchnotes', '/version', '/versioninfo' process_command_patchnotes(message, command, adm) @@ -426,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 0b43997..3c7336e 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 delays related to a missing/misplaced STDOUT.flush calls + +v1.0.00 + Initial Release