You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
heatbot/commands.rb

46 lines
1.6 KiB

def validate_incoming_data(message)
auth_chat = @conf['auth_chat']
message = message.message if message.is_a? Telegram::Bot::Types::CallbackQuery
return "Received message is not from a valid source! Type: \"#{message.chat.type}\". Ignoring." if ! @allowed_sources.include?(message.chat.type)
return true
end
def message_from_admin?(message, adm)
if adm.include?(message.from.id)
puts "Command is from an admin. [" + "#{message.from.username}".green.bold + "]"
return true
else
puts "Command is NOT from an admin! [" + "#{message.from.username}".yellow.bold + "]"
return false
end
end
def is_chat_authorized?(message, auth_chat)
if auth_chat.include?(message.chat.id)
puts "Group [" + "#{message.chat.id}".green.bold + "][" + "#{message.chat.title}".green + "] is authorized"
return true
else
puts "Group [" + "#{message.chat.id}".red.bold + "][" + "#{message.chat.title}".red + "] is NOT authorized!"
return false
end
end
def process_command_patchnotes(message, command, adm)
if is_chat_authorized?(message, @auth_chat) || message_from_admin?(message, adm)
reply = `cat patchnotes.txt`
else
reply = "I am not authorized to provide this information here."
end
return reply
end
def process_command_check(message, command, adm)
if is_chat_authorized?(message, @auth_chat) || message_from_admin?(message, adm)
reply = `cat fakeoutput.txt`
else
reply = "I am not authorized to provide this information here."
end
return reply
end