Top Level Namespace

Defined Under Namespace

Classes: AdminUser, Array, Event, Hash, Plugin, PluginBuilder, PluginManager, Settings, String, Time, Timer, Tty, Zmb

Instance Method Summary collapse

Instance Method Details

#error(message) ⇒ Object



61
62
63
# File 'bin/zmb', line 61

def error(message)
  puts "#{Tty.blue}[ #{Tty.red}!! #{Tty.blue}]#{Tty.reset} #{message}"
end

#notice(message) ⇒ Object



65
66
67
# File 'bin/zmb', line 65

def notice(message)
  puts "#{Tty.blue}[#{Tty.reset} ok #{Tty.blue}]#{Tty.reset} #{message}"
end

#question(message) ⇒ Object



53
54
55
# File 'bin/zmb', line 53

def question(message)
  print "#{Tty.blue}[ #{Tty.yellow}?? #{Tty.blue}]#{Tty.reset} #{message}"
end

#question_bool(message) ⇒ Object



69
70
71
72
73
# File 'bin/zmb', line 69

def question_bool(message)
  question(message + ' (yes/no): ')
  answer = gets.chomp
  answer == 'yes' or answer == 'y'
end

#question_string(message = '') ⇒ Object



75
76
77
78
79
80
81
82
# File 'bin/zmb', line 75

def question_string(message='')
  message += ': ' unless message == ''
  question(message)
  answer = gets.chomp
  
  return nil if answer == ''
  answer
end

#warning(message) ⇒ Object



57
58
59
# File 'bin/zmb', line 57

def warning(message)
  puts "#{Tty.blue}[ #{Tty.yellow}** #{Tty.blue}]#{Tty.reset} #{message}"
end

#wizard(zmb, plugin) ⇒ Object



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'bin/zmb', line 84

def wizard(zmb, plugin)
  STDOUT.flush
  
  if question_bool("Would you like to add the #{plugin.name} plugin? #{plugin.description}") then
    if plugin.multi_instances? then
      instance = question_string("What would you like to name this instance of #{plugin.name}?")
    else
      instance = plugin.name
    end
    
    if not instance then
      notice "Must supply instance name, if this plugin should only be loaded once such as commands or users then you can call it that."
      return wizard(zmb, plugin)
    end
    
    zmb.setup(plugin.name, instance)
    obj = zmb.plugin_manager.plugin plugin.name
    if obj.respond_to?('wizard') then
      settings = zmb.settings_manager.setting(instance)
      settings['plugin'] = plugin.name
      
      obj.wizard.each do |key, value|
        if value.has_key?('help') then
          set = question_string("#{value['help']} (default=#{value['default']})")
          settings[key] = set if set
        end
      end
      
      zmb.settings_manager.save(instance, settings)
    end
    zmb.load instance
  end
end