No value added; preparing massive rewrite

pull/1/head
Aaron Johnson 6 years ago
parent c5063e4933
commit fc862ade07

@ -35,10 +35,39 @@ def process_command_patchnotes(message, command, adm)
end end
def process_command_check(message, command, adm) 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) if is_chat_authorized?(message, @auth_chat) || message_from_admin?(message, adm)
#reply = `scripts/tempf.py` #reply = `scripts/tempf.py`
#some interactive code to select a probe #some interactive code to select a probe
select_loc = "Aisle 12-3" select_loc = "Server Room: Intake"
#end interactive code #end interactive code
#probe = @probes[0] #set manually for now #probe = @probes[0] #set manually for now
reply = "" reply = ""
@ -59,4 +88,3 @@ def process_command_check(message, command, adm)
end end
return reply return reply
end end

@ -207,6 +207,8 @@ def handle_message(message)
reply = "User ID: #{message.from.id}\nChat ID: #{message.chat.id}" reply = "User ID: #{message.from.id}\nChat ID: #{message.chat.id}"
when '/check' when '/check'
reply = process_command_check(message, command, adm) reply = process_command_check(message, command, adm)
when '/test'
reply = process_command_test(message, command, adm)
when '/pp', '/debug' when '/pp', '/debug'
pp message pp message
reply = "Confirmation: Message debug information sent to console." reply = "Confirmation: Message debug information sent to console."
@ -225,7 +227,13 @@ Telegram::Bot::Client.run(token) do |bot|
validation = validate_incoming_data(message) validation = validate_incoming_data(message)
#puts "DEBUG: #{validation}" #puts "DEBUG: #{validation}"
if 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 ..... " print timestamp + ": Sending ..... "
if ! message.text.nil? if ! message.text.nil?
bot.api.send_message(chat_id: message.chat.id, text: "#{reply}") bot.api.send_message(chat_id: message.chat.id, text: "#{reply}")

Loading…
Cancel
Save