From a1ad62aece998bef7d62cab8fa31a839d1d16ef8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Mon, 17 Nov 2014 07:00:19 +0100 Subject: [PATCH] =?utf8?q?Store=20a=20bot=E2=80=99s=20channel.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/main/java/net/pterodactylus/xdcc/core/Core.java | 3 ++- src/main/java/net/pterodactylus/xdcc/data/Bot.java | 16 +++++++--------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/main/java/net/pterodactylus/xdcc/core/Core.java b/src/main/java/net/pterodactylus/xdcc/core/Core.java index b6fb400..d4e5155 100644 --- a/src/main/java/net/pterodactylus/xdcc/core/Core.java +++ b/src/main/java/net/pterodactylus/xdcc/core/Core.java @@ -739,7 +739,8 @@ public class Core extends AbstractExecutionThreadService { Bot bot; synchronized (networkBots) { if (!networkBots.contains(network.get(), channelMessageReceived.source().nick().get())) { - bot = new Bot(network.get(), channelMessageReceived.source().nick().get()); + bot = new Bot(network.get(), channelMessageReceived.channel(), + channelMessageReceived.source().nick().get()); networkBots.put(network.get(), channelMessageReceived.source().nick().get(), bot); eventBus.post(new BotAdded(bot)); } else { diff --git a/src/main/java/net/pterodactylus/xdcc/data/Bot.java b/src/main/java/net/pterodactylus/xdcc/data/Bot.java index 96d91b6..211dde7 100644 --- a/src/main/java/net/pterodactylus/xdcc/data/Bot.java +++ b/src/main/java/net/pterodactylus/xdcc/data/Bot.java @@ -35,6 +35,7 @@ public class Bot implements Iterable { /** The network this bot is on. */ private final Network network; + private final String channel; /** The packs this bot carries. */ private final Map packs = Maps.newHashMap(); @@ -42,16 +43,9 @@ public class Bot implements Iterable { /** The current name of the bot. */ private String name; - /** - * Creates a new bot. - * - * @param network - * The network the bot is on - * @param name - * The name of the bot - */ - public Bot(Network network, String name) { + public Bot(Network network, String channel, String name) { this.network = checkNotNull(network, "network must not be null"); + this.channel = checkNotNull(channel, "channel must not be null"); this.name = checkNotNull(name, "name must not be null"); } @@ -68,6 +62,10 @@ public class Bot implements Iterable { return network; } + public String channel() { + return channel; + } + /** * Returns the current name of this bot. * -- 2.7.4