Search in sources :

Example 1 with Configuration

use of org.pircbotx.Configuration in project downlords-faf-client by FAForever.

the class PircBotXChatServiceTest method testConnect.

@Test
@SuppressWarnings("unchecked")
public void testConnect() throws Exception {
    ArgumentCaptor<Configuration> captor = ArgumentCaptor.forClass(Configuration.class);
    when(userService.getUserId()).thenReturn(681);
    connect();
    botStartedFuture.get(TIMEOUT, TIMEOUT_UNIT);
    verify(pircBotX).startBot();
    verify(pircBotXFactory).createPircBotX(captor.capture());
    Configuration configuration = captor.getValue();
    assertThat(configuration.getName(), is(CHAT_USER_NAME));
    assertThat(configuration.getLogin(), is("681"));
    assertThat(configuration.getRealName(), is(CHAT_USER_NAME));
    assertThat(configuration.getServers().get(0).getHostname(), is(LOOPBACK_ADDRESS.getHostAddress()));
    assertThat(configuration.getServers().get(0).getPort(), is(IRC_SERVER_PORT));
}
Also used : Configuration(org.pircbotx.Configuration) Test(org.junit.Test) AbstractPlainJavaFxTest(com.faforever.client.test.AbstractPlainJavaFxTest)

Example 2 with Configuration

use of org.pircbotx.Configuration in project downlords-faf-client by FAForever.

the class PircBotXChatService method onNotice.

private void onNotice(NoticeEvent event) {
    Configuration config = event.getBot().getConfiguration();
    UserHostmask hostmask = event.getUserHostmask();
    if (config.getNickservOnSuccess() != null && containsIgnoreCase(hostmask.getHostmask(), config.getNickservNick())) {
        String message = event.getMessage();
        if (containsIgnoreCase(message, config.getNickservOnSuccess()) || containsIgnoreCase(message, "registered under your account")) {
            onIdentified();
        } else if (message.contains("isn't registered")) {
            pircBotX.sendIRC().message(config.getNickservNick(), format("register %s %s@users.faforever.com", getPassword(), userService.getUsername()));
        } else if (message.contains(" registered")) {
            // We just registered and are now identified
            onIdentified();
        } else if (message.contains("choose a different nick")) {
            // The server didn't accept our IDENTIFY command, well then, let's send a private message to nickserv manually
            sendIdentify(config);
        }
    }
}
Also used : Configuration(org.pircbotx.Configuration) UserHostmask(org.pircbotx.UserHostmask)

Aggregations

Configuration (org.pircbotx.Configuration)2 AbstractPlainJavaFxTest (com.faforever.client.test.AbstractPlainJavaFxTest)1 Test (org.junit.Test)1 UserHostmask (org.pircbotx.UserHostmask)1