|
1 | | -/** |
| 1 | +/** |
2 | 2 | * Copyright © 2012-2013 Bruce Cowan <bruce@bcowan.me.uk> |
3 | 3 | * Copyright © 2012-2013 Joseph Walton-Rivers <webpigeon@unitycoders.co.uk> |
4 | 4 | * |
5 | 5 | * This file is part of uc_PircBotX. |
6 | 6 | * |
7 | | - * uc_PircBotX is free software: you can redistribute it and/or modify |
8 | | - * it under the terms of the GNU General Public License as published by |
9 | | - * the Free Software Foundation, either version 3 of the License, or |
10 | | - * (at your option) any later version. |
| 7 | + * uc_PircBotX is free software: you can redistribute it and/or modify it under |
| 8 | + * the terms of the GNU General Public License as published by the Free Software |
| 9 | + * Foundation, either version 3 of the License, or (at your option) any later |
| 10 | + * version. |
11 | 11 | * |
12 | | - * uc_PircBotX is distributed in the hope that it will be useful, |
13 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | | - * GNU General Public License for more details. |
| 12 | + * uc_PircBotX is distributed in the hope that it will be useful, but WITHOUT |
| 13 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 14 | + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
| 15 | + * details. |
16 | 16 | * |
17 | | - * You should have received a copy of the GNU General Public License |
18 | | - * along with uc_PircBotX. If not, see <http://www.gnu.org/licenses/>. |
| 17 | + * You should have received a copy of the GNU General Public License along with |
| 18 | + * uc_PircBotX. If not, see <http://www.gnu.org/licenses/>. |
19 | 19 | */ |
20 | 20 | package uk.co.unitycoders.pircbotx; |
21 | 21 |
|
|
35 | 35 |
|
36 | 36 | /** |
37 | 37 | * The actual bot itself. |
38 | | - * |
| 38 | + * |
39 | 39 | * @author Bruce Cowan |
40 | 40 | */ |
41 | | -public class Bot |
42 | | -{ |
43 | | - public static void main(String[] args) throws Exception |
44 | | - { |
45 | | - // Bot Configuration |
46 | | - Configuration config = ConfigurationManager.loadConfig(); |
47 | | - |
48 | | - CommandProcessor processor = new CommandProcessor(config.trigger); |
| 41 | +public class Bot { |
| 42 | + |
| 43 | + public static void main(String[] args) throws Exception { |
| 44 | + // Bot Configuration |
| 45 | + Configuration config = ConfigurationManager.loadConfig(); |
| 46 | + |
| 47 | + CommandProcessor processor = new CommandProcessor(config.trigger); |
| 48 | + |
| 49 | + ProfileManager profiles = new ProfileManager(DBConnection.getProfileModel()); |
| 50 | + DateTimeCommand dtCmd = new DateTimeCommand(); |
49 | 51 |
|
50 | | - ProfileManager profiles = new ProfileManager(DBConnection.getProfileModel()); |
51 | | - DateTimeCommand dtCmd = new DateTimeCommand(); |
| 52 | + // Commands |
| 53 | + processor.register("rand", new RandCommand()); |
| 54 | + processor.register("time", dtCmd); |
| 55 | + processor.register("date", dtCmd); |
| 56 | + processor.register("datetime", dtCmd); |
| 57 | + processor.register("lart", new LartCommand()); |
| 58 | + processor.register("killertrout", new KillerTroutCommand()); |
| 59 | + processor.register("joins", new JoinsCommand()); |
| 60 | + processor.register("calc", new CalcCommand()); |
| 61 | + processor.register("karma", new KarmaCommand()); |
| 62 | + processor.register("profile", new ProfileCommand(profiles)); |
| 63 | + processor.register("help", new HelpCommand(processor)); |
52 | 64 |
|
53 | | - // Commands |
54 | | - processor.register("rand", new RandCommand()); |
55 | | - processor.register("time", dtCmd); |
56 | | - processor.register("date", dtCmd); |
57 | | - processor.register("datetime", dtCmd); |
58 | | - processor.register("lart", new LartCommand()); |
59 | | - processor.register("killertrout", new KillerTroutCommand()); |
60 | | - processor.register("joins", new JoinsCommand()); |
61 | | - processor.register("calc", new CalcCommand()); |
62 | | - processor.register("karma", new KarmaCommand()); |
63 | | - processor.register("profile", new ProfileCommand(profiles)); |
64 | | - processor.register("help", new HelpCommand(processor)); |
| 65 | + PircBotX bot = new PircBotX(); |
| 66 | + ListenerManager<? extends PircBotX> manager = bot.getListenerManager(); |
65 | 67 |
|
66 | | - PircBotX bot = new PircBotX(); |
67 | | - ListenerManager<? extends PircBotX> manager = bot.getListenerManager(); |
| 68 | + // Listeners |
| 69 | + manager.addListener(new CommandListener(processor)); |
| 70 | + manager.addListener(new LinesListener()); |
| 71 | + manager.addListener(JoinsListener.getInstance()); |
68 | 72 |
|
69 | | - // Listeners |
70 | | - manager.addListener(new CommandListener(processor)); |
71 | | - manager.addListener(new LinesListener()); |
72 | | - manager.addListener(JoinsListener.getInstance()); |
| 73 | + // Snapshot (1.8-SNAPSHOT) only |
| 74 | + bot.setAutoReconnect(true); |
| 75 | + bot.setAutoReconnectChannels(true); |
73 | 76 |
|
74 | | - // Snapshot (1.8-SNAPSHOT) only |
75 | | - bot.setAutoReconnect(true); |
76 | | - bot.setAutoReconnectChannels(true); |
| 77 | + try { |
| 78 | + bot.setName(config.nick); |
| 79 | + if (config.ssl) { |
| 80 | + bot.connect(config.host, config.port, SSLSocketFactory.getDefault()); |
| 81 | + } else { |
| 82 | + bot.connect(config.host, config.port); |
| 83 | + } |
77 | 84 |
|
78 | | - try |
79 | | - { |
80 | | - bot.setName(config.nick); |
81 | | - if (config.ssl) { |
82 | | - bot.connect(config.host, config.port, SSLSocketFactory.getDefault()); |
83 | | - } else { |
84 | | - bot.connect(config.host, config.port); |
85 | | - } |
86 | | - |
87 | | - for(String channel : config.channels) { |
88 | | - bot.joinChannel(channel); |
89 | | - } |
90 | | - bot.setVerbose(true); |
91 | | - } catch (Exception e) |
92 | | - { |
93 | | - e.printStackTrace(); |
94 | | - } |
95 | | - } |
| 85 | + for (String channel : config.channels) { |
| 86 | + bot.joinChannel(channel); |
| 87 | + } |
| 88 | + bot.setVerbose(true); |
| 89 | + } catch (Exception e) { |
| 90 | + e.printStackTrace(); |
| 91 | + } |
| 92 | + } |
96 | 93 | } |
0 commit comments