From e8f44866c348c0f4c180e6b5962d4fc94ad65790 Mon Sep 17 00:00:00 2001 From: Aaron Johnson Date: Thu, 12 Sep 2019 19:55:41 -0500 Subject: [PATCH] Added /c alias and sanity check for temperature unit conf --- run.rb | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/run.rb b/run.rb index 8c948ca..87120c9 100755 --- a/run.rb +++ b/run.rb @@ -22,6 +22,7 @@ admin = @conf['admin'] @auth_chat = @conf['authorized_chats'] @allowed_sources = @conf['allowed_sources'] @probes = @conf['probes'] +@tunit = @conf['units'] ### Begin sanity check ### STDOUT.sync = true @@ -100,6 +101,14 @@ if @auth_chat.nil? else print "OK\n".green.bold end +print "Checking temperature units .............. " +if @tunit.nil? + errcount += 1 + print "FAIL!\n\n".red.bold + puts "Error(#{errcount.to_s}): No temperature probes configured! Bot will serve no purpose. Continuing anyway....\n\n" +else + print "OK\n".green.bold +end print "Checking probes list .................... " if @probes.nil? errcount += 1 @@ -122,6 +131,11 @@ puts "Authorized administrator IDs: #{admin}" puts "Authorized chat IDs: #{@auth_chat}" puts "Bot token: #{@token}" puts "Temporary direcotry: #{@tmpdir}" +puts "Temperature unit: #{@tunit}" +puts "Probes loaded:" +@probes.each do |k,v| + puts " [#{k}] #{v["loc"].to_s}" +end puts "Start time: " + timestamp + "\n\n\n\n" STDOUT.flush @@ -148,7 +162,7 @@ def ack_callback(message, display_message = true) begin Telegram::Bot::Client.run(@token) do |bot| if display_message == true - bot.api.editMessageText(chat_id: message.message.chat.id, message_id: message.message.message_id, text: "#{message.from.username}Request received. Please wait...", reply_markup: "") #Removes buttons. Changes text + bot.api.editMessageText(chat_id: message.message.chat.id, message_id: message.message.message_id, text: "Request received. Please wait...", reply_markup: "") #Removes buttons. Changes text bot.api.answerCallbackQuery(callback_query_id: message.id, show_alert: false, text: "Request received. Please wait...") #Sends a pop-up notification else bot.api.deleteMessage(chat_id: message.message.chat.id, message_id: message.message.message_id) #Deletes message and buttons @@ -245,7 +259,7 @@ def handle_message(message) process_command_location(message, command, adm) when '/whoami', '/chatinfo' process_command_chatinfo(message) - when '/check' + when '/check', '/c' process_command_check(message, command, adm) when '/test' process_command_test(message, command, adm)