Search in sources :

Example 1 with Channel

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

the class Bot method onJoin.

@Override
public void onJoin(JoinEvent event) throws Exception {
    super.onJoin(event);
    Channel channel = event.getChannel();
    if (currentChannel == null || !currentChannel.equals(channel)) {
        TwitchChatMod.addNotification(new TranslatableText("text.twitchchat.bot.connected", this.channel));
        currentChannel = channel;
    }
}
Also used : TranslatableText(net.minecraft.text.TranslatableText) Channel(org.pircbotx.Channel)

Example 2 with Channel

use of org.pircbotx.Channel in project ircbot-plugin by jenkinsci.

the class IRCConnection method send.

public void send(String target, String text) throws IMException {
    Channel channel = this.pircConnection.getUserChannelDao().getChannel(target);
    boolean useColors = this.descriptor.isUseColors();
    if (useColors) {
        String mode = channel.getMode();
        if (mode.contains("c")) {
            LOGGER.warning("Bot is configured to use colors, but channel " + target + " disallows colors!");
            useColors = false;
        }
    }
    // IRC doesn't support multiline messages (see http://stackoverflow.com/questions/7039478/linebreak-irc-protocol)
    // therefore we split the message on line breaks and send each line as its own message:
    String[] lines = text.split("\\r?\\n|\\r");
    for (String line : lines) {
        if (useColors) {
            line = IRCColorizer.colorize(line);
        }
        if (this.descriptor.isUseNotice()) {
            this.pircConnection.sendIRC().notice(target, line);
        } else {
            this.pircConnection.sendIRC().message(target, line);
        }
    }
}
Also used : Channel(org.pircbotx.Channel)

Example 3 with Channel

use of org.pircbotx.Channel 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)

Example 4 with Channel

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

the class Helper method getNamesFromTarget.

public static ImmutableSortedSet<String> getNamesFromTarget(String target) {
    try {
        Channel channel = IRCBot.bot.getUserChannelDao().getChannel(target);
        channel.createSnapshot();
        return channel.getUsersNicks();
    } catch (Exception e) {
    // error handling code
    }
    return AntiPings;
}
Also used : Channel(org.pircbotx.Channel)

Example 5 with Channel

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

the class Helper method getRandomUser.

public static String getRandomUser(GenericMessageEvent event, ArrayList<String> blacklist) {
    if (event instanceof GenericChannelUserEvent && ((GenericChannelUserEvent) event).getChannel() != null) {
        Channel channel = ((GenericChannelUserEvent) event).getChannel();
        int size = channel.getUsersNicks().size();
        // In real life, the Random object should be rather more shared than this
        int item = new Random().nextInt(size);
        int i = 0;
        for (String obj : channel.getUsersNicks()) {
            if (i >= item && !blacklist.contains(obj))
                return obj;
            i++;
        }
    }
    return event.getUser().getNick();
}
Also used : GenericChannelUserEvent(org.pircbotx.hooks.types.GenericChannelUserEvent) Channel(org.pircbotx.Channel)

Aggregations

Channel (org.pircbotx.Channel)8 PreparedStatement (java.sql.PreparedStatement)2 ResultSet (java.sql.ResultSet)2 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)2 DateFormat (java.text.DateFormat)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 HashSet (java.util.HashSet)1 TranslatableText (net.minecraft.text.TranslatableText)1 User (org.pircbotx.User)1 UserLevel (org.pircbotx.UserLevel)1 GenericChannelUserEvent (org.pircbotx.hooks.types.GenericChannelUserEvent)1 GenericMessageEvent (org.pircbotx.hooks.types.GenericMessageEvent)1 Command (pcl.lc.irc.entryClasses.Command)1 CommandArgument (pcl.lc.irc.entryClasses.CommandArgument)1 CommandArgumentParser (pcl.lc.irc.entryClasses.CommandArgumentParser)1 CommandChainStateObject (pcl.lc.utils.CommandChainStateObject)1