diff --git a/commands.rb b/commands.rb index 2a76bdd..2c42a9c 100644 --- a/commands.rb +++ b/commands.rb @@ -35,10 +35,39 @@ def process_command_patchnotes(message, command, adm) end def process_command_check(message, command, adm) + if is_chat_authorized?(message, @auth_chat) || message_from_admin?(message, adm) + #begin interactive code + options = [ ] + @probes.each do |k,v| + button_text = v + options.insert(-1, Telegram::Bot::Types::InlineKeyboardButton.new(text: button_text, callback_data: "#{k}")) + end + #end interactive code + #probe = @probes[0] #set manually for now + reply = "N/A" + #hostdata = host_lookup(select_loc) + #puts "var:".blue+" hostdata".blue.bold+"::".bold + hostdata.to_s + #if ! hostdata.empty? + # hostdata.each do |k,v| + # puts "match:".blue+" host".blue.bold+"::".bold + k.to_s + # reply += k.to_s+"\n" + # end + #else + # reply = "No matching locations!" + # puts "hostdata is empty!" + #end + puts reply + else + reply = "I am not authorized to provide this information here." + end + return reply +end + +def process_command_test(message, command, adm) if is_chat_authorized?(message, @auth_chat) || message_from_admin?(message, adm) #reply = `scripts/tempf.py` #some interactive code to select a probe - select_loc = "Aisle 12-3" + select_loc = "Server Room: Intake" #end interactive code #probe = @probes[0] #set manually for now reply = "" @@ -59,4 +88,3 @@ def process_command_check(message, command, adm) end return reply end - diff --git a/run.rb b/run.rb index e2a8709..33785a3 100755 --- a/run.rb +++ b/run.rb @@ -207,6 +207,8 @@ def handle_message(message) reply = "User ID: #{message.from.id}\nChat ID: #{message.chat.id}" when '/check' reply = process_command_check(message, command, adm) + when '/test' + reply = process_command_test(message, command, adm) when '/pp', '/debug' pp message reply = "Confirmation: Message debug information sent to console." @@ -225,7 +227,13 @@ Telegram::Bot::Client.run(token) do |bot| validation = validate_incoming_data(message) #puts "DEBUG: #{validation}" if validation - reply = handle_message(message) + #reply = handle_message(message) + #case message + # when Telegram::Bot::Types::Message + reply = handle_message(message) #entrypoint for all messages + # when Telegram::Bot::Types::CallbackQuery + # reply = handle_callback_query(message) #entrypoint for all callback queries + #end print timestamp + ": Sending ..... " if ! message.text.nil? bot.api.send_message(chat_id: message.chat.id, text: "#{reply}")