blob: ac0c6a12894560dccff512d723d1058b01e6fd79 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
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";
}
public String getMessages()
{
return this.messages;
}
}
}
|