public Cyborg() { if (instance != null) { throw new IllegalAccessError("There is already an instance of Cyborg!"); } pluginManager = new CommonPluginManager(this); pluginManager.registerPluginLoader(CommonPluginLoader.class); eventManager = new SimpleEventManager(); commandManager = new CommonCommandManager(); // Register Internal Listeners bot.getListenerManager().addListener(new PircBotXListener()); eventManager.registerEvents(new CommandListener(), this); eventManager.registerEvents(new InternalListener(), this); // Setup Bot \\ bot.setVerbose(StartupArguments.getInstance().isVerbose()); bot.setName(Settings.getNick()); bot.setLogin(Settings.getIdent()); setMessageDelay(Settings.getMessageDelay()); // Register Default Commands \\ commandManager.registerCommands( new Named() { @Override public String getName() { return Cyborg.class.getCanonicalName(); } }, TerminalCommands.class, new EmptyConstructorInjector()); instance = this; }
public void partChannel(Channel channel, String reason) { PartEvent partEvent = new PartEvent(channel, reason); partEvent = eventManager.callEvent(partEvent); if (!partEvent.isCancelled()) { if (partEvent.getReason() != null) { bot.partChannel(partEvent.getChannel(), partEvent.getReason()); } else { bot.partChannel(channel); } } }
public void joinChannel(String channel, String key) { JoinEvent joinEvent = new JoinEvent(channel, key); joinEvent = eventManager.callEvent(joinEvent); if (!joinEvent.isCancelled()) { if (joinEvent.getKey() != null) { bot.joinChannel(joinEvent.getChannel(), joinEvent.getKey()); } else { bot.joinChannel(joinEvent.getChannel()); } } }
public void sendNotice(String target, String message) { SendNoticeEvent event = new SendNoticeEvent(target, message); event = eventManager.callEvent(event); if (!event.isCancelled()) { if (event.getNotice().contains(newLine)) { for (String line : event.getNotice().split(newLine)) { bot.sendNotice(event.getTarget(), line); } } else { bot.sendNotice(event.getTarget(), event.getNotice()); } } }
public void setTopic(Channel channel, String topic) { SetChannelTopicEvent event = eventManager.callEvent(new SetChannelTopicEvent(channel, topic)); if (!event.isCancelled()) { bot.setTopic(event.getChannel(), event.getTopic()); } }