Search in sources :

Example 1 with User

use of org.pircbotx.User in project twitch-chat by pblop.

the class Bot method onMessage.

@Override
public void onMessage(MessageEvent event) throws Exception {
    String message = event.getMessage();
    System.out.println("TWITCH MESSAGE: " + message);
    User user = event.getUser();
    if (user != null) {
        ImmutableMap<String, String> v3Tags = event.getV3Tags();
        if (v3Tags != null) {
            String nick = user.getNick();
            if (!ModConfig.getConfig().getIgnoreList().contains(nick)) {
                String colorTag = v3Tags.get("color");
                Formatting formattingColor;
                if (isFormattingColorCached(nick)) {
                    formattingColor = getFormattingColor(nick);
                } else {
                    if (colorTag.equals("")) {
                        formattingColor = CalculateMinecraftColor.getDefaultUserColor(nick);
                    } else {
                        Color userColor = Color.decode(colorTag);
                        formattingColor = CalculateMinecraftColor.findNearestMinecraftColor(userColor);
                    }
                    putFormattingColor(nick, formattingColor);
                }
                String formattedTime = TwitchChatMod.formatTMISentTimestamp(v3Tags.get("tmi-sent-ts"));
                TwitchChatMod.addTwitchMessage(formattedTime, nick, message, formattingColor, false);
            }
        } else {
            System.out.println("Message with no v3tags: " + event.getMessage());
        }
    } else {
        System.out.println("NON-USER MESSAGE" + event.getMessage());
    }
}
Also used : User(org.pircbotx.User) Color(java.awt.Color) Formatting(net.minecraft.util.Formatting)

Example 2 with User

use of org.pircbotx.User in project twitch-chat by pblop.

the class Bot method onAction.

// Handle /me
@Override
public void onAction(ActionEvent event) throws Exception {
    User user = event.getUser();
    if (user != null) {
        String nick = user.getNick();
        if (!ModConfig.getConfig().getIgnoreList().contains(nick.toLowerCase())) {
            String formattedTime = TwitchChatMod.formatTMISentTimestamp(event.getTimestamp());
            Formatting formattingColor;
            if (isFormattingColorCached(nick)) {
                formattingColor = getFormattingColor(nick);
            } else {
                formattingColor = CalculateMinecraftColor.getDefaultUserColor(nick);
                putFormattingColor(nick, formattingColor);
            }
            TwitchChatMod.addTwitchMessage(formattedTime, nick, event.getMessage(), formattingColor, true);
        }
    } else {
        System.out.println("NON-USER ACTION" + event.getMessage());
    }
}
Also used : User(org.pircbotx.User) Formatting(net.minecraft.util.Formatting)

Example 3 with User

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

the class Seen method onPart.

@Override
public void onPart(final PartEvent 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, "Parting");
            updateSeen.execute();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
Also used : User(org.pircbotx.User) PreparedStatement(java.sql.PreparedStatement)

Example 4 with User

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

the class TimedBans method setTimedBan.

public static void setTimedBan(Channel channel, String nick, String hostname, String length, String reason, String module) {
    try {
        reason = reason.trim();
        long time = Helper.getFutureTime(length);
        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, channel.getName());
        addTimedBan.setString(2, nick);
        for (User u : channel.getUsers()) {
            if (u.getNick().equals(nick)) {
                hostname = u.getHostname();
            }
        }
        addTimedBan.setString(3, "*!*@" + hostname);
        addTimedBan.setLong(4, time);
        addTimedBan.setString(5, module);
        addTimedBan.setString(6, reason);
        addTimedBan.setString(7, "ban");
        addTimedBan.executeUpdate();
        IRCBot.bot.sendIRC().message("chanserv", "ban " + channel.getName() + " " + nick);
        IRCBot.bot.sendIRC().message("chanserv", "kick " + channel.getName() + " " + nick + " Reason: " + reason + " | For: " + length + " | Expires: " + expiresTime);
    } catch (Exception e) {
        e.printStackTrace();
        IRCBot.bot.sendIRC().message(channel.getName(), "DNSBL" + ": " + "An error occurred while processing this automated ban");
    }
}
Also used : User(org.pircbotx.User) PreparedStatement(java.sql.PreparedStatement) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Example 5 with User

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

the class Account method getUserFromString.

public static User getUserFromString(String user, MessageEvent event) {
    Channel chan = event.getChannel();
    Iterator<User> it = chan.getUsers().iterator();
    while (it.hasNext()) {
        User userInfo = it.next();
        String userName = userInfo.getNick();
        if (userName.equals(user)) {
            return userInfo;
        }
    }
    return null;
}
Also used : User(org.pircbotx.User) Channel(org.pircbotx.Channel)

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