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

- (Object) error(message)



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

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

- (Object) notice(message)



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

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

- (Object) question(message)



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

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

- (Object) question_bool(message)



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

- (Object) question_string(message = ''))



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

- (Object) warning(message)



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

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

- (Object) wizard(zmb, plugin)



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