From: David ‘Bombe’ Roden Date: Wed, 10 Apr 2013 06:24:50 +0000 (+0200) Subject: Add “stats” command. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=dba9fd00094c51b311cf4e9108ed6729302e5a9a;p=xudocci.git Add “stats” command. --- diff --git a/src/main/java/net/pterodactylus/xdcc/ui/stdin/CommandReader.java b/src/main/java/net/pterodactylus/xdcc/ui/stdin/CommandReader.java index 497c5fd..ad6cde1 100644 --- a/src/main/java/net/pterodactylus/xdcc/ui/stdin/CommandReader.java +++ b/src/main/java/net/pterodactylus/xdcc/ui/stdin/CommandReader.java @@ -20,8 +20,10 @@ package net.pterodactylus.xdcc.ui.stdin; import java.io.BufferedReader; import java.io.Reader; import java.io.Writer; +import java.util.Collection; import java.util.Collections; import java.util.List; +import java.util.Set; import net.pterodactylus.irc.DccReceiver; import net.pterodactylus.xdcc.core.Core; @@ -29,6 +31,7 @@ import net.pterodactylus.xdcc.data.Bot; import net.pterodactylus.xdcc.data.Pack; import com.google.common.collect.Lists; +import com.google.common.collect.Sets; import com.google.common.primitives.Ints; import com.google.common.util.concurrent.AbstractExecutionThreadService; @@ -115,6 +118,21 @@ public class CommandReader extends AbstractExecutionThreadService { if ((index != null) && (index < lastResult.size())) { core.fetch(lastResult.get(index).bot(), lastResult.get(index).pack()); } + } else if (words[0].equalsIgnoreCase("stats")) { + int configuredChannelsCount = core.channels().size(); + int joinedChannelsCount = core.joinedChannels().size(); + int extraChannelsCount = core.extraChannels().size(); + Collection bots = core.bots(); + Set packNames = Sets.newHashSet(); + int packsCount = 0; + for (Bot bot : bots) { + packsCount += bot.packs().size(); + for (Pack pack : bot) { + packNames.add(pack.name()); + } + } + + writer.write(String.format("%d channels (%d joined, %d extra), %d bots offering %d packs (%d unique).\n", configuredChannelsCount, joinedChannelsCount, extraChannelsCount, bots.size(), packsCount, packNames.size())); } lastLine = line;