diff options
author | Simon Rettberg | 2020-02-24 14:54:53 +0100 |
---|---|---|
committer | Simon Rettberg | 2020-02-24 14:54:53 +0100 |
commit | 2a086a64bde0efba1e4a7ac1126ca60fec0ed94b (patch) | |
tree | 87f62f710c61f0e461a5809b2623c103795fee03 /src/main/java/org/openslx/taskmanager | |
parent | scripts/system-restore: Run post-restore scripts (diff) | |
download | tmlite-bwlp-2a086a64bde0efba1e4a7ac1126ca60fec0ed94b.tar.gz tmlite-bwlp-2a086a64bde0efba1e4a7ac1126ca60fec0ed94b.tar.xz tmlite-bwlp-2a086a64bde0efba1e4a7ac1126ca60fec0ed94b.zip |
[IrcNotification] New Task
Diffstat (limited to 'src/main/java/org/openslx/taskmanager')
-rw-r--r-- | src/main/java/org/openslx/taskmanager/tasks/IrcNotification.java | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/src/main/java/org/openslx/taskmanager/tasks/IrcNotification.java b/src/main/java/org/openslx/taskmanager/tasks/IrcNotification.java new file mode 100644 index 0000000..92f29f4 --- /dev/null +++ b/src/main/java/org/openslx/taskmanager/tasks/IrcNotification.java @@ -0,0 +1,68 @@ +package org.openslx.taskmanager.tasks; + +import java.util.ArrayList; + +import org.openslx.satserver.util.IrcClient; +import org.openslx.satserver.util.Util; +import org.openslx.taskmanager.api.AbstractTask; + +import com.google.gson.annotations.Expose; + +public class IrcNotification extends AbstractTask +{ + + @Expose + private String serverAddress; + + @Expose + private String channel; + + @Expose + private String message; + + @Expose + private String nickName; + + private Output status = new Output(); + + @Override + protected boolean initTask() + { + this.setStatusObject( status ); + if ( Util.isEmpty( serverAddress ) ) { + status.add( "serverAddress empty" ); + return false; + } + if ( Util.isEmpty( channel ) ) { + status.add( "channel empty" ); + return false; + } + if ( Util.isEmpty( message ) ) { + status.add( "message empty" ); + return false; + } + if ( Util.isEmpty( nickName ) ) { + nickName = "bwlp-" + (int) ( Math.random() * 10000 ); + } + return true; + } + + @Override + protected boolean execute() + { + ArrayList<String> errors = new ArrayList<>( 0 ); + IrcClient.sendMessage( serverAddress, channel, nickName, message, errors ); + return true; + } + + public static class Output + { + private String messages; + + public void add( String message ) + { + this.messages += message + "\n"; + } + } + +} |