Возможность работы в консольном режиме
This commit is contained in:
parent
e8b0acfcde
commit
fad24bf8bd
@ -15,9 +15,43 @@ public final class ControlFrame extends JFrame {
|
||||
private static final String TITLE = "Лена-бот";
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
boolean noGUI = false;
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
switch (args[i]) {
|
||||
case "-nogui":
|
||||
case "-cli":
|
||||
noGUI = true;
|
||||
break;
|
||||
case "-prefix":
|
||||
if (i + 1 >= args.length) break;
|
||||
i++;
|
||||
Config.ANSWER_PREFIX = args[i];
|
||||
break;
|
||||
case "-name":
|
||||
case "-names":
|
||||
if (i + 1 >= args.length) break;
|
||||
i++;
|
||||
Config.BOT_NAMES = args[i];
|
||||
break;
|
||||
case "-token":
|
||||
if (i + 1 >= args.length) break;
|
||||
i++;
|
||||
Config.access_token = args[i];
|
||||
break;
|
||||
case "-gettoken":
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (noGUI) {
|
||||
StatisticsProcessor.init();
|
||||
new Thread(new MainThread(true)).start();
|
||||
} else {
|
||||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||
EventQueue.invokeLater(() -> new ControlFrame().setVisible(true));
|
||||
}
|
||||
}
|
||||
|
||||
public ControlFrame() {
|
||||
super(TITLE);
|
||||
@ -44,7 +78,7 @@ public final class ControlFrame extends JFrame {
|
||||
settingsPanel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
|
||||
settingsPanel.setLayout(new BoxLayout(settingsPanel, BoxLayout.PAGE_AXIS));
|
||||
final JTextField accessTokenField = createTextFieldLine(settingsPanel,
|
||||
"Access token:", String.valueOf(Config.access_token));
|
||||
"Access token:", Config.access_token);
|
||||
final JTextField botNamesTokenField = createTextFieldLine(settingsPanel,
|
||||
"Обращение:", String.valueOf(Config.BOT_NAMES));
|
||||
final JTextField answerPrefixField = createTextFieldLine(settingsPanel,
|
||||
|
@ -77,6 +77,7 @@ public final class Log {
|
||||
}
|
||||
|
||||
public static void insertTo(StyledDocument doc, String text, String style) {
|
||||
if (doc == null) return;
|
||||
try {
|
||||
doc.insertString(doc.getLength(), text, doc.getStyle(style));
|
||||
} catch (BadLocationException ex) { }
|
||||
|
Loading…
Reference in New Issue
Block a user