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));
}
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));
}
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;
}
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();
}
}
}
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();
}
}
}
Aggregations