A corporation manager and dashboard for EVE Online
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 
 

76 rader
2.3 KiB

  1. require 'io/console'
  2. namespace :calefaction do
  3. desc "Sets some initial database values and creates an admin user"
  4. task setup: :environment do
  5. print "Enter your corporation's name: "
  6. corp_name = STDIN.gets.chomp
  7. print "\nEnter your corporation's ID (this is visible in the URL for "\
  8. "your corp's page on \nzKillboard, among other places): "
  9. corp_id = STDIN.gets.to_i
  10. if corp_id <= 0
  11. puts 'Corporation ID must be a positive integer. Stopping.'
  12. next
  13. end
  14. print "\nEnter your character's API key ID (create one at\n"\
  15. "https://community.eveonline.com/support/api-key/createpredefined?accessMask=8): "
  16. user_api_key = STDIN.gets.chomp
  17. print "\nEnter the verification code for the key you just entered: "
  18. user_api_verify = STDIN.gets.chomp
  19. user = User.new(api_key: user_api_key, api_verify: user_api_verify,
  20. is_admin: true, is_corp: true)
  21. chars = user.char_names
  22. if chars.empty?
  23. puts "The given API key is invalid, has no characters, or something "\
  24. "else is wrong\nwith the EVE API right now..."
  25. next
  26. end
  27. if chars.length == 1
  28. user.name = chars.first
  29. else
  30. puts "\nChoose a character:"
  31. chars.each_with_index do |name, i|
  32. puts " [#{i}]: #{name}"
  33. end
  34. puts "Enter the number next to your chosen character: "
  35. loop do
  36. index = STDIN.gets.to_i
  37. break unless index >= chars.length || index < 0
  38. puts "Bad input; try again: "
  39. end
  40. user.name = chars[index]
  41. end
  42. unless user.member_of? corp_id
  43. puts 'You are not a member of the given corporation. Stopping.'
  44. next
  45. end
  46. print "\nEnter your email address (used for password resets; may be blank): "
  47. user.email = STDIN.gets.chomp
  48. user.email = nil if user.email.empty?
  49. print "\nEnter your new password (to log in to the website, **NOT** for EVE!): "
  50. user.password = STDIN.noecho(&:gets).chomp
  51. puts
  52. print "\nConfirm the password: "
  53. if user.password != STDIN.noecho(&:gets).chomp
  54. puts "\nPasswords do not match. Stopping."
  55. next
  56. end
  57. puts
  58. AdminSetting.where(key: %w(corp_name site_name)).update_all(value: corp_name)
  59. AdminSetting.find_by(key: 'corp_id').update(value: corp_id)
  60. user.save
  61. puts "\nDone!"
  62. end
  63. end