From 37f0a1127b203e2126bb29be8fc2ec1b2fb680ed Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sun, 7 Apr 2013 22:47:00 +0200 Subject: [PATCH] Add events for messages. --- .../irc/event/ChannelMessageReceived.java | 76 ++++++++++++++++++++++ .../irc/event/PrivateMessageReceived.java | 74 +++++++++++++++++++++ 2 files changed, 150 insertions(+) create mode 100644 src/main/java/net/pterodactylus/irc/event/ChannelMessageReceived.java create mode 100644 src/main/java/net/pterodactylus/irc/event/PrivateMessageReceived.java diff --git a/src/main/java/net/pterodactylus/irc/event/ChannelMessageReceived.java b/src/main/java/net/pterodactylus/irc/event/ChannelMessageReceived.java new file mode 100644 index 0000000..5cb6349 --- /dev/null +++ b/src/main/java/net/pterodactylus/irc/event/ChannelMessageReceived.java @@ -0,0 +1,76 @@ +/* + * XdccDownloader - MessageReceived.java - Copyright © 2013 David Roden + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.pterodactylus.irc.event; + +import net.pterodactylus.irc.Connection; +import net.pterodactylus.irc.Source; + +/** + * Notifies a listener that a channel message was received. + * + * @author David ‘Bombe’ Roden + */ +public class ChannelMessageReceived extends AbstractChannelEvent { + + /** The source of the message. */ + private final Source source; + + /** The text of the message. */ + private final String message; + + /** + * Creates a new channel message received event. + * + * @param connection + * The connection the event occured on + * @param channel + * The channel of the message + * @param source + * The source of the message + * @param message + * The text of the message + */ + public ChannelMessageReceived(Connection connection, String channel, Source source, String message) { + super(connection, channel); + this.source = source; + this.message = message; + } + + // + // ACCESSORS + // + + /** + * Returns the source of the message. + * + * @return The source of the message + */ + public Source source() { + return source; + } + + /** + * Returns the text of the message. + * + * @return The text of the message + */ + public String message() { + return message; + } + +} diff --git a/src/main/java/net/pterodactylus/irc/event/PrivateMessageReceived.java b/src/main/java/net/pterodactylus/irc/event/PrivateMessageReceived.java new file mode 100644 index 0000000..b679f7c --- /dev/null +++ b/src/main/java/net/pterodactylus/irc/event/PrivateMessageReceived.java @@ -0,0 +1,74 @@ +/* + * XdccDownloader - PrivateMessageReceived.java - Copyright © 2013 David Roden + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.pterodactylus.irc.event; + +import net.pterodactylus.irc.Connection; +import net.pterodactylus.irc.Source; + +/** + * Notifies a listener that a new private message was received. + * + * @author David ‘Bombe’ Roden + */ +public class PrivateMessageReceived extends AbstractConnectionEvent { + + /** The source of the message. */ + private final Source source; + + /** The text of the message. */ + private final String message; + + /** + * Creates a new private message received event. + * + * @param connection + * The connection the event occured on + * @param source + * The source of the message + * @param message + * The text of the message + */ + public PrivateMessageReceived(Connection connection, Source source, String message) { + super(connection); + this.source = source; + this.message = message; + } + + // + // ACCESSORS + // + + /** + * Returns the source of the message. + * + * @return The source of the message + */ + public Source source() { + return source; + } + + /** + * Returns the text of the message. + * + * @return The text of the message + */ + public String message() { + return message; + } + +} -- 2.7.4