Search in sources :

Example 6 with User

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

the class PircBotXChatServiceTest method testSuppressFoeMessage.

@Test
public void testSuppressFoeMessage() throws Exception {
    String message = "private message";
    preferences.getChat().setHideFoeMessages(true);
    User user = mock(User.class);
    when(user.getNick()).thenReturn(chatUser1.getUsername());
    Player playerMock = mock(Player.class);
    when(playerService.getPlayerForUsername(chatUser1.getUsername())).thenReturn(playerMock);
    when(playerMock.getSocialStatus()).thenReturn(SocialStatus.FOE);
    connect();
    firePircBotXEvent(createPrivateMessageEvent(user, message));
    verify(eventBus, never()).post(any(Object.class));
}
Also used : Player(com.faforever.client.player.Player) User(org.pircbotx.User) Test(org.junit.Test) AbstractPlainJavaFxTest(com.faforever.client.test.AbstractPlainJavaFxTest)

Example 7 with User

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

the class PircBotXChatServiceTest method testOnModeratorJoined.

@Test
public void testOnModeratorJoined() throws Exception {
    connect();
    User moderator = mock(User.class);
    when(moderator.getNick()).thenReturn("moderator");
    when(moderator.getChannels()).thenReturn(ImmutableSortedSet.of(defaultChannel));
    when(moderator.getUserLevels(defaultChannel)).thenReturn(ImmutableSortedSet.of(UserLevel.OWNER));
    joinChannel(defaultChannel, moderator);
    firePircBotXEvent(createJoinEvent(defaultChannel, moderator));
    ChatUser chatUserModerator = instance.getOrCreateChatUser(moderator.getNick());
    assertTrue(chatUserModerator.moderatorInChannelsProperty().getValue().contains(DEFAULT_CHANNEL_NAME));
}
Also used : User(org.pircbotx.User) Test(org.junit.Test) AbstractPlainJavaFxTest(com.faforever.client.test.AbstractPlainJavaFxTest)

Example 8 with User

use of org.pircbotx.User in project LanteaBot by PC-Logix.

the class TimedBans method setTimedEvent.

private String setTimedEvent(String type, String senderNick, String targetChannel, String targetNick, String timeStr, String reason, User[] users) throws Exception {
    String hostname = null;
    long time = 0;
    try {
        time = Helper.getFutureTime(timeStr);
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
        return "Unable to parse '" + timeStr + "'. " + e.getMessage();
    }
    SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy hh:mm:ss a");
    String expiresTime = sdf.format(new Date(time));
    PreparedStatement addTimedBan = Database.getPreparedStatement("addTimedBan");
    // 1 channel,2 username,3 hostmask,4 expires,5 placedby,6 reason,7 type
    addTimedBan.setString(1, targetChannel);
    addTimedBan.setString(2, targetNick);
    if (users != null) {
        for (User u : users) {
            if (u.getNick().equals(targetNick)) {
                hostname = "*!*@" + u.getHostname();
            }
        }
    }
    if (hostname == null) {
        hostname = targetNick;
    }
    addTimedBan.setString(3, hostname);
    addTimedBan.setLong(4, time);
    addTimedBan.setString(5, senderNick);
    addTimedBan.setString(6, reason);
    addTimedBan.setString(7, type);
    addTimedBan.executeUpdate();
    if (type.equals("ban")) {
        Helper.sendMessage("chanserv", "ban " + targetChannel + " " + targetNick);
        Helper.sendMessage("chanserv", "kick " + targetChannel + " " + targetNick + " Reason: " + reason + " | For: " + timeStr + " | Expires: " + expiresTime);
    } else {
        Helper.sendMessage("chanserv", "quiet " + targetChannel + " " + targetNick);
    }
    return null;
}
Also used : User(org.pircbotx.User) PreparedStatement(java.sql.PreparedStatement) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Example 9 with User

use of org.pircbotx.User in project LanteaBot by PC-Logix.

the class Seen method onJoin.

@Override
public void onJoin(final JoinEvent event) {
    if (!event.getChannel().getMode().contains("s")) {
        User sender = event.getUser();
        try {
            PreparedStatement updateSeen = Database.getPreparedStatement("updateLastSeen");
            updateSeen.setString(1, sender.getNick().toLowerCase());
            updateSeen.setLong(2, System.currentTimeMillis());
            updateSeen.setString(3, "Joining");
            updateSeen.execute();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
Also used : User(org.pircbotx.User) PreparedStatement(java.sql.PreparedStatement)

Example 10 with User

use of org.pircbotx.User in project LanteaBot by PC-Logix.

the class Seen method onKick.

@Override
public void onKick(final KickEvent event) {
    if (!event.getChannel().getMode().contains("s")) {
        User sender = event.getUser();
        try {
            PreparedStatement updateSeen = Database.getPreparedStatement("updateLastSeen");
            updateSeen.setString(1, sender.getNick().toLowerCase());
            updateSeen.setLong(2, System.currentTimeMillis());
            updateSeen.setString(3, "Being Kicked");
            updateSeen.execute();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
Also used : User(org.pircbotx.User) PreparedStatement(java.sql.PreparedStatement)

Aggregations

User (org.pircbotx.User)20 PreparedStatement (java.sql.PreparedStatement)10 ChatMessageEvent (com.faforever.client.chat.event.ChatMessageEvent)5 Player (com.faforever.client.player.Player)3 AbstractPlainJavaFxTest (com.faforever.client.test.AbstractPlainJavaFxTest)3 SimpleDateFormat (java.text.SimpleDateFormat)3 Date (java.util.Date)3 MessageEvent (org.pircbotx.hooks.events.MessageEvent)3 PrivateMessageEvent (org.pircbotx.hooks.events.PrivateMessageEvent)3 GenericMessageEvent (org.pircbotx.hooks.types.GenericMessageEvent)3 ResultSet (java.sql.ResultSet)2 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 CompletableFuture (java.util.concurrent.CompletableFuture)2 Formatting (net.minecraft.util.Formatting)2 Test (org.junit.Test)2 FafClientApplication (com.faforever.client.FafClientApplication)1 CUSTOM (com.faforever.client.chat.ChatColorMode.CUSTOM)1 RANDOM (com.faforever.client.chat.ChatColorMode.RANDOM)1 ClientProperties (com.faforever.client.config.ClientProperties)1