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