|
@@ -22,8 +22,8 @@
|
22
|
22
|
|
23
|
23
|
package com.dmdirc.addons.parser_twitter.actions;
|
24
|
24
|
|
25
|
|
-import com.dmdirc.Main;
|
26
|
25
|
import com.dmdirc.Server;
|
|
26
|
+import com.dmdirc.ServerManager;
|
27
|
27
|
import com.dmdirc.interfaces.actions.ActionComponent;
|
28
|
28
|
import com.dmdirc.addons.parser_twitter.Twitter;
|
29
|
29
|
import com.dmdirc.addons.parser_twitter.api.TwitterStatus;
|
|
@@ -34,19 +34,30 @@ import com.dmdirc.parser.interfaces.Parser;
|
34
|
34
|
* Action components which expose Twitter functionality.
|
35
|
35
|
*
|
36
|
36
|
* @since 0.6.4
|
37
|
|
- * @author chris
|
38
|
37
|
*/
|
39
|
|
-public enum TwitterActionComponents implements ActionComponent {
|
|
38
|
+public class TwitterActionComponents {
|
40
|
39
|
|
41
|
40
|
/** Takes a twitter channel name (&12345) and returns the status. */
|
42
|
|
- TWITTER_CHANNEL_NAME_STATUS {
|
|
41
|
+ public static class ChannelNameStatus implements ActionComponent {
|
|
42
|
+
|
|
43
|
+ /** Server manager to use to get servers. */
|
|
44
|
+ private final ServerManager serverManager;
|
|
45
|
+
|
|
46
|
+ /**
|
|
47
|
+ * Creates a new instance of {@link ChannelNameStatus}.
|
|
48
|
+ *
|
|
49
|
+ * @param serverManager The server manager to use to get servers.
|
|
50
|
+ */
|
|
51
|
+ public ChannelNameStatus(final ServerManager serverManager) {
|
|
52
|
+ this.serverManager = serverManager;
|
|
53
|
+ }
|
43
|
54
|
|
44
|
55
|
/** {@inheritDoc} */
|
45
|
56
|
@Override
|
46
|
57
|
public Object get(final Object arg) {
|
47
|
58
|
final long id = Long.parseLong(((String) arg).substring(1));
|
48
|
59
|
|
49
|
|
- for (Server server : Main.mainInstance.getServerManager().getServers()) {
|
|
60
|
+ for (Server server : serverManager.getServers()) {
|
50
|
61
|
final Parser parser = server.getParser();
|
51
|
62
|
|
52
|
63
|
if (parser instanceof Twitter) {
|
|
@@ -79,10 +90,16 @@ public enum TwitterActionComponents implements ActionComponent {
|
79
|
90
|
return "twitter status (if a Twitter channel link)";
|
80
|
91
|
}
|
81
|
92
|
|
82
|
|
- },
|
|
93
|
+ /** {@inheritDoc} */
|
|
94
|
+ @Override
|
|
95
|
+ public String name() {
|
|
96
|
+ return "TWITTER_CHANNEL_NAME_STATUS";
|
|
97
|
+ }
|
|
98
|
+
|
|
99
|
+ };
|
83
|
100
|
|
84
|
101
|
/** Returns the user who created a tweet. */
|
85
|
|
- TWITTER_STATUS_USER {
|
|
102
|
+ public static class StatusUser implements ActionComponent {
|
86
|
103
|
|
87
|
104
|
/** {@inheritDoc} */
|
88
|
105
|
@Override
|
|
@@ -108,10 +125,16 @@ public enum TwitterActionComponents implements ActionComponent {
|
108
|
125
|
return "user";
|
109
|
126
|
}
|
110
|
127
|
|
111
|
|
- },
|
|
128
|
+ /** {@inheritDoc} */
|
|
129
|
+ @Override
|
|
130
|
+ public String name() {
|
|
131
|
+ return "TWITTER_STATUS_USER";
|
|
132
|
+ }
|
|
133
|
+
|
|
134
|
+ };
|
112
|
135
|
|
113
|
136
|
/** Returns the screen name of a twitter user. */
|
114
|
|
- TWITTER_USER_SCREENNAME {
|
|
137
|
+ public static class UserScreenName implements ActionComponent {
|
115
|
138
|
|
116
|
139
|
/** {@inheritDoc} */
|
117
|
140
|
@Override
|
|
@@ -137,6 +160,12 @@ public enum TwitterActionComponents implements ActionComponent {
|
137
|
160
|
return "screen name";
|
138
|
161
|
}
|
139
|
162
|
|
|
163
|
+ /** {@inheritDoc} */
|
|
164
|
+ @Override
|
|
165
|
+ public String name() {
|
|
166
|
+ return "TWITTER_USER_SCREENNAME";
|
|
167
|
+ }
|
|
168
|
+
|
140
|
169
|
};
|
141
|
170
|
|
142
|
171
|
}
|