-
-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
API for bans, abstracted to support quiets/exempt #122
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
src/main/java/org/kitteh/irc/client/library/element/mode/ModeInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/* | ||
* * Copyright (C) 2013-2016 Matt Baxter http://kitteh.org | ||
* | ||
* Permission is hereby granted, free of charge, to any person | ||
* obtaining a copy of this software and associated documentation | ||
* files (the "Software"), to deal in the Software without | ||
* restriction, including without limitation the rights to use, copy, | ||
* modify, merge, publish, distribute, sublicense, and/or sell copies | ||
* of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be | ||
* included in all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
package org.kitteh.irc.client.library.element.mode; | ||
|
||
import org.kitteh.irc.client.library.Client; | ||
import org.kitteh.irc.client.library.command.ChannelModeCommand; | ||
import org.kitteh.irc.client.library.element.Channel; | ||
import org.kitteh.irc.client.library.util.Mask; | ||
|
||
import javax.annotation.Nonnull; | ||
import java.time.Instant; | ||
import java.util.Optional; | ||
|
||
/** | ||
* Represents a type A mode information entry. | ||
*/ | ||
public interface ModeInfo { | ||
/** | ||
* Gets the name of the party listed as creating the entry. This may be a | ||
* nickname, a service name, a server name, etc. | ||
* | ||
* @return name, if known, of who created this entry | ||
*/ | ||
@Nonnull | ||
Optional<String> getCreator(); | ||
|
||
/** | ||
* Gets the channel for which this entry exists. | ||
* | ||
* @return the channel | ||
*/ | ||
@Nonnull | ||
Channel getChannel(); | ||
|
||
/** | ||
* Gets the client that received this information. | ||
* | ||
* @return the client | ||
*/ | ||
@Nonnull | ||
Client getClient(); | ||
|
||
/** | ||
* Gets the mask. | ||
* | ||
* @return the mask | ||
*/ | ||
@Nonnull | ||
Mask getMask(); | ||
|
||
/** | ||
* Gets the mode for which this info exists. | ||
* | ||
* @return the mode | ||
*/ | ||
@Nonnull | ||
ChannelMode getMode(); | ||
|
||
/** | ||
* Gets the time at which this entry was created. | ||
* | ||
* @return creation time, if known | ||
*/ | ||
@Nonnull | ||
Optional<Instant> getCreationTime(); | ||
|
||
/** | ||
* Attempts to remove this item from the channel. | ||
*/ | ||
default void remove() { | ||
new ChannelModeCommand(this.getClient(), this.getChannel().getName()).add(false, this.getMode(), this.getMask().asString()).execute(); | ||
} | ||
} |
78 changes: 78 additions & 0 deletions
78
src/main/java/org/kitteh/irc/client/library/event/channel/ChannelModeInfoListEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* | ||
* * Copyright (C) 2013-2016 Matt Baxter http://kitteh.org | ||
* | ||
* Permission is hereby granted, free of charge, to any person | ||
* obtaining a copy of this software and associated documentation | ||
* files (the "Software"), to deal in the Software without | ||
* restriction, including without limitation the rights to use, copy, | ||
* modify, merge, publish, distribute, sublicense, and/or sell copies | ||
* of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be | ||
* included in all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
package org.kitteh.irc.client.library.event.channel; | ||
|
||
import org.kitteh.irc.client.library.Client; | ||
import org.kitteh.irc.client.library.element.Channel; | ||
import org.kitteh.irc.client.library.element.ServerMessage; | ||
import org.kitteh.irc.client.library.element.mode.ChannelMode; | ||
import org.kitteh.irc.client.library.element.mode.ModeInfo; | ||
import org.kitteh.irc.client.library.event.abstractbase.ChannelEventBase; | ||
|
||
import javax.annotation.Nonnull; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
/** | ||
* A list of mode info is available! | ||
*/ | ||
public class ChannelModeInfoListEvent extends ChannelEventBase { | ||
private final ChannelMode mode; | ||
private final List<ModeInfo> info; | ||
|
||
/** | ||
* Constructs the event. | ||
* | ||
* @param client client for which this is occurring | ||
* @param originalMessages original messages | ||
* @param channel channel with this info | ||
* @param mode mode for which the info exists | ||
* @param info list of info | ||
*/ | ||
public ChannelModeInfoListEvent(@Nonnull Client client, @Nonnull List<ServerMessage> originalMessages, @Nonnull Channel channel, @Nonnull ChannelMode mode, @Nonnull List<ModeInfo> info) { | ||
super(client, originalMessages, channel); | ||
this.mode = mode; | ||
this.info = Collections.unmodifiableList(info); | ||
} | ||
|
||
/** | ||
* Gets the mode info's mode. | ||
* | ||
* @return mode | ||
*/ | ||
@Nonnull | ||
public ChannelMode getMode() { | ||
return this.mode; | ||
} | ||
|
||
/** | ||
* Gets the channel's mode info. | ||
* | ||
* @return info | ||
*/ | ||
@Nonnull | ||
public List<ModeInfo> getModeInfo() { | ||
return this.info; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume this is for bans, quiets, etc.
There's currently no way, that I can see, to determine which type of list this is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From latest commit - "Needs way of knowing it's a ban"