use of lib.pircbot.User in project Botnak by Gocnak.
the class ListenerName method createUserPopup.
public static void createUserPopup(String channel, String name, Component parent, int x, int y) {
JPopupMenu popupMenu = new JPopupMenu();
ListenerNameActionListener nameActionListener = new ListenerNameActionListener();
if (!(channel.equals("") || channel.equalsIgnoreCase("all"))) {
if (GUIMain.viewer != null) {
//get the user in question
User u = Settings.channelManager.getUser(name, false);
//get yourself
User main = Settings.channelManager.getUser(Settings.accountManager.getUserAccount().getName(), false);
if (main != null) {
//don't worry about it
int count = 0;
//can't ban broadcaster or admin/staff/global mod
if (u != null && (u.isAdmin() || u.isGlobalMod() || u.isStaff() || name.equalsIgnoreCase(channel.replace("#", ""))))
count++;
//can't ban other mods if you aren't the broadcaster
if (u != null && (!main.getNick().equalsIgnoreCase(channel.replace("#", "")) && (main.isOp(channel) && u.isOp(channel))))
count++;
//Feature added: the ability to purge spammers' messages, even if they leave
if (count == 0 && (channel.replace("#", "").equalsIgnoreCase(main.getNick()) || main.isOp(channel))) {
//it's your channel OR you're op and the other user isn't.
JMenuItem menuItem;
menuItem = new JMenuItem("Purge " + name);
menuItem.addActionListener(nameActionListener);
popupMenu.add(menuItem);
menuItem = new JMenuItem("Timeout " + name);
menuItem.addActionListener(nameActionListener);
popupMenu.add(menuItem);
menuItem = new JMenuItem("Ban " + name);
menuItem.addActionListener(nameActionListener);
popupMenu.add(menuItem);
if (channel.replace("#", "").equalsIgnoreCase(main.getNick()) && u != null) {
//you can only (un)mod people in your chat that are(n't) mods
menuItem = new JMenuItem((u.isOp(channel) ? "Un-mod " : "Mod ") + name);
menuItem.addActionListener(nameActionListener);
popupMenu.add(menuItem);
}
}
}
}
}
JMenuItem menuItem = new JMenuItem("Go to " + name + "'s channel");
menuItem.addActionListener(nameActionListener);
popupMenu.add(menuItem);
popupMenu.show(parent, x, y);
}
use of lib.pircbot.User in project Botnak by Gocnak.
the class FaceManager method handleEmoteSet.
public static void handleEmoteSet(String emotes) {
if (checkedEmoteSets)
return;
ThreadEngine.submit(() -> {
try {
checkedEmoteSets = true;
String line = APIRequests.Twitch.getEmoteSet(emotes);
if (!line.isEmpty()) {
User main = Settings.channelManager.getUser(Settings.accountManager.getUserAccount().getName(), true);
JSONObject init = new JSONObject(line);
String[] keys = emotes.split(",");
JSONObject emote_sets = init.getJSONObject("emoticon_sets");
for (String s : keys) {
JSONArray set = emote_sets.getJSONArray(s);
for (int i = 0; i < set.length(); i++) {
JSONObject emote = set.getJSONObject(i);
int ID = emote.getInt("id");
main.addEmote(ID);
if (doneWithTwitchFaces) {
if (twitchFaceMap.get(ID) == null) {
downloadEmote(ID);
}
}
}
}
}
} catch (Exception e) {
GUIMain.log("FaceManager: Failed to download EmoteSets!");
checkedEmoteSets = false;
}
});
}
use of lib.pircbot.User in project Botnak by Gocnak.
the class ChatPane method onMessage.
/**
* This is the main message method when somebody sends a message to the channel.
*
* @param m The message from the chat.
*/
public void onMessage(MessageWrapper m, boolean showChannel) {
if (textPane == null)
return;
Message message = m.getLocal();
String sender = message.getSender().toLowerCase();
String channel = message.getChannel();
String mess = message.getContent();
boolean isMe = (message.getType() == Message.MessageType.ACTION_MESSAGE);
try {
print(m, "\n" + getTime(), GUIMain.norm);
User u = Settings.channelManager.getUser(sender, true);
SimpleAttributeSet user = getUserSet(u);
if (channel.substring(1).equals(sender)) {
insertIcon(m, IconEnum.BROADCASTER, null);
}
if (u.isOp(channel)) {
if (!channel.substring(1).equals(sender) && !u.isStaff() && !u.isAdmin() && !u.isGlobalMod()) {
//not the broadcaster again
insertIcon(m, IconEnum.MOD, null);
}
}
if (u.isGlobalMod()) {
insertIcon(m, IconEnum.GLOBAL_MOD, null);
}
if (u.isStaff()) {
insertIcon(m, IconEnum.STAFF, null);
}
if (u.isAdmin()) {
insertIcon(m, IconEnum.ADMIN, null);
}
boolean isSubscriber = u.isSubscriber(channel);
if (isSubscriber) {
insertIcon(m, IconEnum.SUBSCRIBER, channel);
} else {
if (Utils.isMainChannel(channel)) {
Optional<Subscriber> sub = Settings.subscriberManager.getSubscriber(sender);
if (sub.isPresent() && !sub.get().isActive()) {
insertIcon(m, IconEnum.EX_SUBSCRIBER, channel);
}
}
}
if (u.isTurbo()) {
insertIcon(m, IconEnum.TURBO, null);
}
if (u.isPrime())
insertIcon(m, IconEnum.PRIME, null);
//Cheering
int cheerTotal = u.getCheer(channel);
if (cheerTotal > 0) {
insertIcon(m, Donor.getCheerStatus(cheerTotal), null);
}
// Third party donor
if (Settings.showDonorIcons.getValue()) {
if (u.isDonor()) {
insertIcon(m, u.getDonationStatus(), null);
}
}
//name stuff
print(m, " ", GUIMain.norm);
SimpleAttributeSet userColor = new SimpleAttributeSet(user);
FaceManager.handleNameFaces(sender, user);
if (showChannel) {
print(m, determineName(u), user);
print(m, " (" + channel.substring(1) + ")" + (isMe ? " " : ": "), GUIMain.norm);
} else {
print(m, determineName(u), user);
print(m, (!isMe ? ": " : " "), userColor);
}
//keyword?
SimpleAttributeSet set;
if (Utils.mentionsKeyword(mess)) {
set = Utils.getSetForKeyword(mess);
} else {
set = (isMe ? userColor : GUIMain.norm);
}
//URL, Faces, rest of message
printMessage(m, mess, set, u);
if (BotnakTrayIcon.shouldDisplayMentions() && !Utils.isTabSelected(index)) {
if (mess.toLowerCase().contains(Settings.accountManager.getUserAccount().getName().toLowerCase())) {
GUIMain.getSystemTrayIcon().displayMention(m.getLocal());
}
}
if (Utils.isMainChannel(channel))
//check status of the sub, has it been a month?
Settings.subscriberManager.updateSubscriber(u, channel, isSubscriber);
if (shouldPulse())
GUIMain.instance.pulseTab(this);
} catch (Exception e) {
GUIMain.log(e);
}
}
use of lib.pircbot.User in project Botnak by Gocnak.
the class IRCViewer method onConnect.
@Override
public void onConnect() {
Settings.channelManager.addUser(new User(getViewer().getNick()));
GUIMain.channelSet.forEach(this::doConnect);
GUIMain.updateTitle(null);
}
use of lib.pircbot.User in project Botnak by Gocnak.
the class UserManager method readAndUpdate.
private void readAndUpdate(JSONArray toRead, GUIViewerList list, GUIViewerList.ViewerType type) {
for (int i = 0; i < toRead.length(); i++) {
User u = new User(toRead.getString(i));
switch(type) {
case GLOBAL_MOD:
u.setGlobalMod(true);
break;
case ADMIN:
u.setAdmin(true);
break;
case STAFF:
u.setStaff(true);
break;
default:
break;
}
addUser(u);
collectedUsers.add(toRead.getString(i));
}
list.updateCategory(type, collectedUsers);
collectedUsers.clear();
}
Aggregations