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