From dba9fd00094c51b311cf4e9108ed6729302e5a9a Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Wed, 10 Apr 2013 08:24:50 +0200 Subject: [PATCH] =?utf8?q?Add=20=E2=80=9Cstats=E2=80=9D=20command.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../net/pterodactylus/xdcc/ui/stdin/CommandReader.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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; -- 2.7.4