use of chatty.util.api.StreamInfo in project chatty by chatty.
the class Speedruncom method openCurrentGame.
public void openCurrentGame(Channel chan) {
if (Helper.isRegularChannel(chan.getStreamName())) {
StreamInfo info = twitchApi.getStreamInfo(chan.getStreamName(), null);
if (info.isValid() && !info.getGame().isEmpty()) {
String game = info.getGame();
UrlOpener.openUrlPrompt(chan, "https://speedrun.com/" + replaceForUrl(game));
return;
}
}
UrlOpener.openUrlPrompt(chan, "https://speedrun.com");
}
use of chatty.util.api.StreamInfo in project chatty by chatty.
the class TwitchClient method testCommands.
private void testCommands(Room room, String command, String parameter) {
String channel = room.getChannel();
if (command.equals("addchans")) {
String[] splitSpace = parameter.split(" ");
String[] split2 = splitSpace[0].split(",");
for (String chan : split2) {
// g.printLine(chan, "test");
}
} else if (command.equals("settestuser")) {
String[] split = parameter.split(" ");
createTestUser(split[0], split[1]);
} else if (command.equals("setemoteset")) {
testUser.setEmoteSets(parameter);
} else if (command.equals("setemoteset2")) {
getSpecialUser().setEmoteSets(parameter);
} else if (command.equals("getemoteset")) {
g.printLine(g.emoticons.getEmoticons(Integer.parseInt(parameter)).toString());
} else if (command.equals("testcolor")) {
testUser.setColor(parameter);
} else if (command.equals("testupdatenotification")) {
g.setUpdateAvailable("[test]");
} else if (command.equals("testannouncement")) {
g.setAnnouncementAvailable(Boolean.parseBoolean(parameter));
} else if (command.equals("removechan")) {
g.removeChannel(parameter);
} else if (command.equals("testtimer")) {
new Thread(new TestTimer(this, new Integer(parameter))).start();
} else // }
if (command.equals("bantest")) {
int duration = -1;
String reason = "";
if (parameter != null) {
String[] split = parameter.split(" ", 2);
duration = Integer.parseInt(split[0]);
if (split.length > 1) {
reason = split[1];
}
}
g.userBanned(testUser, duration, reason, null);
} else if (command.equals("bantest2")) {
String[] split = parameter.split(" ", 3);
int duration = -1;
if (split.length > 1) {
duration = Integer.parseInt(split[1]);
}
String reason = "";
if (split.length > 2) {
reason = split[2];
}
g.userBanned(c.getUser(channel, split[0]), duration, reason, null);
} else if (command.equals("userjoined")) {
c.userJoined("#test", parameter);
} else if (command.equals("echomessage")) {
String[] parts = parameter.split(" ");
// g.printMessage(parts[0], testUser, parts[1], false, null, 0);
} else if (command.equals("loadffz")) {
frankerFaceZ.requestEmotes(parameter, true);
} else if (command.equals("testtw")) {
g.showTokenWarning();
} else if (command.equals("tsonline")) {
testStreamInfo.set(parameter, "Game", 123, -1, StreamType.LIVE);
g.addStreamInfo(testStreamInfo);
} else if (command.equals("tsoffline")) {
testStreamInfo.setOffline();
g.addStreamInfo(testStreamInfo);
} else if (command.equals("testspam")) {
g.printLine("test" + spamProtection.getAllowance() + spamProtection.tryMessage());
} else if (command.equals("spamprotectioninfo")) {
g.printSystem("Spam Protection: " + c.getSpamProtectionInfo());
} else if (command.equals("tsv")) {
testStreamInfo.set("Title", "Game", Integer.parseInt(parameter), -1, StreamType.LIVE);
} else if (command.equals("tsvs")) {
System.out.println(testStreamInfo.getViewerStats(true));
} else if (command.equals("tsaoff")) {
StreamInfo info = api.getStreamInfo(g.getActiveStream(), null);
info.setOffline();
} else if (command.equals("tsaon")) {
StreamInfo info = api.getStreamInfo(g.getActiveStream(), null);
info.set("Test", "Game", 12, System.currentTimeMillis() - 1000, StreamType.LIVE);
} else if (command.equals("tston")) {
StreamInfo info = api.getStreamInfo("tduva", null);
info.set("Test 2", "Game", 12, System.currentTimeMillis() - 1000, StreamType.LIVE);
} else if (command.equals("usericonsinfo")) {
usericonManager.debug();
} else if (command.equals("userlisttest")) {
// g.printMessage("test1", testUser, "short message", false, null, 0);
// g.printMessage("test2", testUser, "short message2", false, null, 0);
// g.printCompact("test3", "MOD", testUser);
// g.printCompact("test3", "MOD", testUser);
// g.printCompact("test3", "MOD", testUser);
// g.printCompact("test3", "MOD", testUser);
// g.printCompact("test3", "MOD", testUser);
// g.printCompact("test3", "MOD", testUser);
// g.printCompact("test3", "MOD", testUser);
// g.printMessage("test3", testUser, "longer message abc hmm fwef wef wef wefwe fwe ewfwe fwef wwefwef"
// + "fjwfjfwjefjwefjwef wfejfkwlefjwoefjwf wfjwoeifjwefiowejfef wefjoiwefj", false, null, 0);
// g.printMessage("test3", testUser, "longer message abc hmm fwef wef wef wefwe fwe ewfwe fwef wwefwef"
// + "fjwfjfwjefjwefjwoeifjwefiowejfef wefjoiwefj", false, null, 0);
// g.printMessage("test3", testUser, "longer wef wef wefwe fwe ewfwe fwef wwefwef"
// + "fjwfjfwjefjwefjwef wfejfkwlefjwoefjwf wfjwoeifjwefiowejfef wefjoiwefj", false, null, 0);
// g.printCompact("test4", "MOD", testUser);
// g.printCompact("test5", "MOD", testUser);
// g.printCompact("test6", "MOD", testUser);
// g.printCompact("test7", "MOD", testUser);
// g.printCompact("test8", "MOD", testUser);
// g.printCompact("test9", "MOD", testUser);
// g.printMessage("test10", testUser, "longer message abc hmm fwef wef wef wefwe fwe ewfwe fwef wwefwef"
// + "fjwfjfwjefjwefjwef wfejfkwlefjwoefjwf wfjwoeifjwefiowejfef wefjoiwefj", false, null, 0);
} else if (command.equals("requestfollowers")) {
api.getFollowers(parameter);
} else if (command.equals("simulate2")) {
c.simulate(parameter);
} else if (command.equals("simulate")) {
if (parameter.equals("bits")) {
parameter = "bits " + g.emoticons.getCheerEmotesString(null);
} else if (parameter.equals("bitslocal")) {
parameter = "bits " + g.emoticons.getCheerEmotesString(Helper.toStream(channel));
} else if (parameter.startsWith("bits ")) {
parameter = "bits " + parameter.substring("bits ".length());
}
String raw = RawMessageTest.simulateIRC(channel, parameter, c.getUsername());
if (raw != null) {
c.simulate(raw);
}
} else if (command.equals("lb")) {
String[] split = parameter.split("&");
String message = "";
for (int i = 0; i < split.length; i++) {
if (!message.isEmpty()) {
message += "\r";
}
message += split[i];
}
sendMessage(channel, message);
} else if (command.equals("c1")) {
sendMessage(channel, (char) 1 + parameter);
} else if (command.equals("gc")) {
Runtime.getRuntime().gc();
LogUtil.logMemoryUsage();
} else if (command.equals("wsconnect")) {
frankerFaceZ.connectWs();
} else if (command.equals("wsdisconnect")) {
frankerFaceZ.disconnectWs();
} else if (command.equals("psconnect")) {
pubsub.connect();
} else if (command.equals("psdisconnect")) {
pubsub.disconnect();
} else if (command.equals("modactiontest")) {
List<String> args = new ArrayList<>();
args.add("tirean");
args.add("300");
args.add("still not using LiveSplit Autosplitter D:");
g.printModerationAction(new ModeratorActionData("", "", "tduvatest", "timeout", args, "tduva", ""), false);
} else if (command.equals("modactiontest2")) {
List<String> args = new ArrayList<>();
args.add("tduva");
args.add("fuck and stuff like that, rather long message and whatnot Kappa b " + new Random().nextInt(100));
g.printModerationAction(new ModeratorActionData("", "", parameter == null ? "tduvatest" : parameter, "twitchbot_rejected", args, "twitchbot", "TEST" + Math.random()), false);
} else if (command.equals("repeat")) {
String[] split = parameter.split(" ", 2);
int count = Integer.parseInt(split[0]);
for (int i = 0; i < count; i++) {
commandInput(room, "/" + split[1]);
}
} else if (command.equals("modactiontest3")) {
List<String> args = new ArrayList<>();
args.add("tduva");
g.printModerationAction(new ModeratorActionData("", "", "tduvatest", "approved_twitchbot_message", args, "tduvatest", "TEST" + Math.random()), false);
} else if (command.equals("loadsoferrors")) {
for (int i = 0; i < 10000; i++) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
Helper.unhandledException();
}
});
}
} else if (command.equals("getuserid")) {
if (parameter == null) {
g.printSystem("Parameter required.");
} else {
api.getUserIdAsap(r -> {
String result = r.getData().toString();
if (r.hasError()) {
result += " Error: " + r.getError();
}
g.printSystem(result);
}, parameter.split("[ ,]"));
}
} else if (command.equals("getuserids2")) {
api.getUserIDsTest2(parameter);
} else if (command.equals("getuserids3")) {
api.getUserIDsTest3(parameter);
}
}
use of chatty.util.api.StreamInfo in project chatty by chatty.
the class LiveStreamsList method addListeners.
private void addListeners() {
ComponentListener cl = new ComponentAdapter() {
@Override
public void componentResized(ComponentEvent e) {
// Trick from kleopatra:
// https://stackoverflow.com/questions/7306295/swing-jlist-with-multiline-text-and-dynamic-height
// next line possible if list is of type JXList
// list.invalidateCellSizeCache();
// for core: force cache invalidation by temporarily setting fixed height
setFixedCellHeight(10);
setFixedCellHeight(-1);
}
};
addComponentListener(cl);
JListActionHelper.install(this, (a, l, s) -> {
if (a == Action.CONTEXT_MENU) {
StreamInfosContextMenu m = new StreamInfosContextMenu(s, true);
for (ContextMenuListener cml : contextMenuListeners) {
m.addContextMenuListener(cml);
}
lastContextMenu = m;
m.show(this, l.x, l.y);
} else if (a == Action.ENTER) {
List<String> channels = new ArrayList<>();
s.forEach(si -> channels.add(si.stream));
for (ContextMenuListener cml : contextMenuListeners) {
cml.streamsMenuItemClicked(new ActionEvent(s, 0, "join"), channels);
}
} else if (a == Action.DOUBLE_CLICK || a == Action.SPACE) {
StreamInfo info = getSelectedValue();
if (info != null && liveStreamListener != null) {
liveStreamListener.liveStreamClicked(info);
}
}
});
}
use of chatty.util.api.StreamInfo in project chatty by chatty.
the class LiveStreamsRemovedList method openContextMenu.
/**
* Open context menu for this user, if the event points at one.
*
* @param e
*/
private void openContextMenu(MouseEvent e) {
if (e.isPopupTrigger()) {
selectClicked(e, false);
List<RemovedListItem> selectedItems = list.getSelectedValuesList();
List<StreamInfo> selected = new ArrayList<>();
for (RemovedListItem item : selectedItems) {
selected.add(item.getStreamInfo());
}
StreamInfosContextMenu m = new StreamInfosContextMenu(selected, false);
for (ContextMenuListener cml : contextMenuListeners) {
m.addContextMenuListener(cml);
}
m.show(list, e.getX(), e.getY());
}
}
use of chatty.util.api.StreamInfo in project chatty by chatty.
the class CustomCommands method command.
public synchronized String command(CustomCommand command, Parameters parameters, Room room) {
// Add some more parameters
parameters.put("chan", Helper.toStream(room.getChannel()));
parameters.put("stream", room.getStream());
if (!command.getIdentifiersWithPrefix("stream").isEmpty()) {
System.out.println("request");
String stream = Helper.toValidStream(room.getStream());
StreamInfo streamInfo = api.getStreamInfo(stream, null);
if (streamInfo.isValid()) {
parameters.put("streamstatus", streamInfo.getFullStatus());
if (streamInfo.getOnline()) {
parameters.put("streamuptime", DateTime.agoUptimeCompact2(streamInfo.getTimeStartedWithPicnic()));
parameters.put("streamtitle", streamInfo.getTitle());
parameters.put("streamgame", streamInfo.getGame());
parameters.put("streamviewers", String.valueOf(streamInfo.getViewers()));
}
}
}
// Add parameters for custom replacements
Set<String> customIdentifiers = command.getIdentifiersWithPrefix("_");
for (String identifier : customIdentifiers) {
CustomCommand replacement = getCommand(replacements, identifier, room.getOwnerChannel());
if (replacement != null) {
parameters.put(identifier, replacement.replace(parameters));
}
}
return command.replace(parameters);
}
Aggregations