Skip to content

Commit a70d8d9

Browse files
author
Alvin Reyes
committed
Fixed friend picker response
Modified the action frame bucket assignment locig
1 parent c38cbe0 commit a70d8d9

31 files changed

Lines changed: 183 additions & 219 deletions

src/main/java/co/aurasphere/botmill/kik/KikBotMillContext.java

Lines changed: 75 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import java.util.ArrayList;
2929
import java.util.List;
3030
import co.aurasphere.botmill.kik.configuration.Authentication;
31+
import co.aurasphere.botmill.kik.incoming.event.AnyEvent;
3132
import co.aurasphere.botmill.kik.incoming.event.LinkMessageEvent;
3233
import co.aurasphere.botmill.kik.incoming.event.PictureMessageEvent;
3334
import co.aurasphere.botmill.kik.incoming.event.TextMessageEvent;
@@ -40,135 +41,108 @@
4041
/**
4142
* KikBotMillContext
4243
*
43-
* This class is used to access all globally defined objects being used on the application.
44-
* Developers will be able to do the following using this class:
44+
* This class is used to access all globally defined objects being used on the
45+
* application. Developers will be able to do the following using this class:
4546
*
46-
* - Setup the environment (Api and username)
47-
* - Get and Set the list of domains, action frames and broadcast frames
48-
* - Get and Set the Entrypoints.
47+
* - Setup the environment (Api and username) - Get and Set the list of domains,
48+
* action frames and broadcast frames - Get and Set the Entrypoints.
4949
*
5050
* @author Alvin P. Reyes
5151
*/
5252
public class KikBotMillContext {
53-
53+
5454
/** The instance. */
5555
private static KikBotMillContext instance;
56-
56+
5757
/** The authentication. */
5858
private Authentication authentication;
59-
59+
6060
/** The webhook url. */
6161
private String webhookUrl;
62-
62+
6363
/** The bots. */
6464
private List<KikBotMillEntry> entryPoints;
65-
65+
6666
/** The domains. */
6767
private List<Domain> domains;
68-
68+
6969
/** The action frames. */
7070
private List<Frame> actionFrames;
71-
72-
/** The text message action frames. */
73-
private List<Frame> textMessageActionFrames;
74-
75-
/** The media message action frames. */
76-
private List<Frame> mediaMessageActionFrames;
77-
78-
/** The link message action frames. */
79-
private List<Frame> linkMessageActionFrames;
71+
72+
/** The any event action frames. */
73+
private List<Frame> anyEventActionFrames;
8074

8175
/** The broadcast action frames. */
8276
private List<Frame> broadcastActionFrames;
83-
77+
8478
/**
85-
* Get the list of domains.
86-
*
87-
* @return list of {@link Domain}
79+
* Instantiates a new kik bot mill context.
8880
*/
89-
public List<Domain> getDomains() {
90-
return domains;
81+
public KikBotMillContext() {
82+
this.entryPoints = new ArrayList<KikBotMillEntry>();
83+
this.domains = new ArrayList<Domain>();
84+
this.actionFrames = new ArrayList<Frame>();
85+
this.anyEventActionFrames = new ArrayList<Frame>();
86+
this.broadcastActionFrames = new ArrayList<Frame>();
9187
}
9288

9389
/**
94-
* Get the list of action frames.
90+
* Gets the single instance of KikBotMillContext.
9591
*
96-
* @return list of {@link ActionFrame}
92+
* @return {@link KikBotMillContext} single instance of KikBotMillContext
9793
*/
98-
public List<Frame> getActionFrames() {
99-
return actionFrames;
94+
public static KikBotMillContext getInstance() {
95+
if (instance == null) {
96+
instance = new KikBotMillContext();
97+
}
98+
return instance;
10099
}
101100

102101
/**
103-
* Gets the text message action frames.
102+
* Get the list of domains.
104103
*
105-
* @return list of text message {@link Frame}
104+
* @return list of {@link Domain}
106105
*/
107-
public List<Frame> getTextMessageActionFrames() {
108-
return textMessageActionFrames;
106+
public List<Domain> getDomains() {
107+
return domains;
109108
}
110109

111110
/**
112-
* Gets the media message action frames.
111+
* Get the list of action frames.
113112
*
114-
* @return list of media message {@link Frame}
113+
* @return list of {@link ActionFrame}
115114
*/
116-
public List<Frame> getMediaMessageActionFrames() {
117-
return mediaMessageActionFrames;
115+
public List<Frame> getActionFrames() {
116+
return actionFrames;
118117
}
119118

120119
/**
121-
* Gets the link message action frames.
120+
* Gets the any event action frames.
122121
*
123-
* @return list of link message {@link Frame}
122+
* @return the any event action frames
124123
*/
125-
public List<Frame> getLinkMessageActionFrames() {
126-
return linkMessageActionFrames;
124+
public List<Frame> getAnyEventActionFrames() {
125+
return anyEventActionFrames;
127126
}
128127

129128
/**
130129
* Gets the broadcast message action frames.
131130
*
132-
* @return list of broadcast message{@link Frame}
131+
* @return the broadcast message action frames
133132
*/
134133
public List<Frame> getBroadcastMessageActionFrames() {
135134
return broadcastActionFrames;
136135
}
137136

138-
/**
139-
* Instantiates a new kik bot mill context.
140-
*/
141-
public KikBotMillContext() {
142-
this.entryPoints = new ArrayList<KikBotMillEntry>();
143-
this.domains = new ArrayList<Domain>();
144-
this.actionFrames = new ArrayList<Frame>();
145-
this.textMessageActionFrames = new ArrayList<Frame>();
146-
this.mediaMessageActionFrames = new ArrayList<Frame>();
147-
this.linkMessageActionFrames = new ArrayList<Frame>();
148-
this.broadcastActionFrames = new ArrayList<Frame>();
149-
}
150-
151-
/**
152-
* Gets the single instance of KikBotMillContext.
153-
*
154-
* @return {@link KikBotMillContext} single instance of KikBotMillContext
155-
*/
156-
public static KikBotMillContext getInstance() {
157-
if (instance == null) {
158-
instance = new KikBotMillContext();
159-
}
160-
return instance;
161-
}
162-
163137
/**
164138
* Gets the user.
165139
*
166140
* @return the user
167141
*/
168-
public String getUser(){
142+
public String getUser() {
169143
return this.authentication.getUser();
170144
}
171-
145+
172146
/**
173147
* Gets the api key.
174148
*
@@ -177,37 +151,41 @@ public String getUser(){
177151
public String getApiKey() {
178152
return this.authentication.getApiKey();
179153
}
180-
154+
181155
/**
182156
* Setup.
183157
*
184-
* @param username the username
185-
* @param apiKey the api key
158+
* @param username
159+
* the username
160+
* @param apiKey
161+
* the api key
186162
*/
187163
public void setup(String username, String apiKey) {
188164
this.authentication = new Authentication();
189165
this.authentication.setUser(username);
190166
this.authentication.setApiKey(apiKey);
191167
}
192-
168+
193169
/**
194170
* Register kik bot.
195171
*
196-
* @param kikBotMillEntry the kikBotMillEntry
172+
* @param kikBotMillEntry
173+
* the kikBotMillEntry
197174
*/
198175
public void registerEntryPoint(KikBotMillEntry kikBotMillEntry) {
199176
this.entryPoints.add(kikBotMillEntry);
200177
}
201-
178+
202179
/**
203180
* Sets the web hook url.
204181
*
205-
* @param url the new web hook url
182+
* @param url
183+
* the new web hook url
206184
*/
207185
public void setWebHookUrl(String url) {
208186
this.webhookUrl = url;
209187
}
210-
188+
211189
/**
212190
* Gets the web hook url.
213191
*
@@ -216,58 +194,52 @@ public void setWebHookUrl(String url) {
216194
public String getWebHookUrl() {
217195
return this.webhookUrl;
218196
}
219-
197+
220198
/**
221199
* Register domain.
222200
*
223-
* @param domain the domain
201+
* @param domain
202+
* the domain
224203
*/
225204
public void registerDomain(Domain domain) {
226205
this.domains.add(domain);
227206
}
228-
207+
229208
/**
230209
* Adds the action frame to context.
231210
*
232-
* @param actionFrame the action frame
211+
* @param actionFrame
212+
* the action frame
233213
*/
234214
public void addActionFrameToContext(Frame actionFrame) {
235-
if((actionFrame.getEvent() instanceof TextMessageEvent) || (actionFrame.getEvent() instanceof TextMessagePatternEvent)){
236-
this.textMessageActionFrames.add(actionFrame);
237-
}else if((actionFrame.getEvent() instanceof LinkMessageEvent)) {
238-
this.linkMessageActionFrames.add(actionFrame);
239-
}else if((actionFrame.getEvent() instanceof PictureMessageEvent)
240-
||(actionFrame.getEvent() instanceof VideoMessageEvent)) {
241-
this.mediaMessageActionFrames.add(actionFrame);
242-
}else {
215+
if (actionFrame.getEvent() instanceof AnyEvent) {
216+
this.anyEventActionFrames.add(actionFrame);
217+
} else {
243218
this.actionFrames.add(actionFrame);
244219
}
245220
}
246-
221+
247222
/**
248223
* Adds the action frames to context.
249224
*
250-
* @param frames the frames
225+
* @param frames
226+
* the frames
251227
*/
252228
public void addActionFramesToContext(List<Frame> frames) {
253-
for(Frame actionFrame:frames) {
254-
if((actionFrame.getEvent() instanceof TextMessageEvent) || (actionFrame.getEvent() instanceof TextMessagePatternEvent)){
255-
this.textMessageActionFrames.add(actionFrame);
256-
}else if((actionFrame.getEvent() instanceof LinkMessageEvent)) {
257-
this.linkMessageActionFrames.add(actionFrame);
258-
}else if((actionFrame.getEvent() instanceof PictureMessageEvent)
259-
||(actionFrame.getEvent() instanceof VideoMessageEvent)) {
260-
this.mediaMessageActionFrames.add(actionFrame);
261-
}else {
229+
for (Frame actionFrame : frames) {
230+
if (actionFrame.getEvent() instanceof AnyEvent) {
231+
this.anyEventActionFrames.add(actionFrame);
232+
} else {
262233
this.actionFrames.add(actionFrame);
263234
}
264235
}
265236
}
266-
237+
267238
/**
268239
* Adds the action frame to broadcast.
269240
*
270-
* @param actionFrame the action frame
241+
* @param actionFrame
242+
* the action frame
271243
*/
272244
public void addActionFrameToBroadcast(Frame actionFrame) {
273245
this.broadcastActionFrames.add(actionFrame);

src/main/java/co/aurasphere/botmill/kik/builder/ConfigurationBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
package co.aurasphere.botmill.kik.builder;
2727

2828
import co.aurasphere.botmill.kik.configuration.Configuration;
29-
import co.aurasphere.botmill.kik.configuration.Keyboard;
3029
import co.aurasphere.botmill.kik.model.BaseBuilder;
30+
import co.aurasphere.botmill.kik.model.Keyboard;
3131
import co.aurasphere.botmill.kik.network.NetworkUtils;
3232

3333
/**

src/main/java/co/aurasphere/botmill/kik/builder/KeyboardBuilder.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@
2525
*/
2626
package co.aurasphere.botmill.kik.builder;
2727

28-
import co.aurasphere.botmill.kik.configuration.Keyboard;
29-
import co.aurasphere.botmill.kik.configuration.KeyboardType;
30-
import co.aurasphere.botmill.kik.configuration.Response;
3128
import co.aurasphere.botmill.kik.model.BaseBuilder;
29+
import co.aurasphere.botmill.kik.model.Keyboard;
30+
import co.aurasphere.botmill.kik.model.KeyboardType;
31+
import co.aurasphere.botmill.kik.model.Response;
3232

3333
/**
3434
* The Class KeyboardBuilder.

src/main/java/co/aurasphere/botmill/kik/builder/LinkMessageBuilder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@
2525
*/
2626
package co.aurasphere.botmill.kik.builder;
2727

28-
import co.aurasphere.botmill.kik.configuration.Keyboard;
2928
import co.aurasphere.botmill.kik.model.Attribution;
3029
import co.aurasphere.botmill.kik.model.BaseBuilder;
3130
import co.aurasphere.botmill.kik.model.Buildable;
31+
import co.aurasphere.botmill.kik.model.Keyboard;
3232
import co.aurasphere.botmill.kik.model.Keyboardable;
3333
import co.aurasphere.botmill.kik.model.KikJsData;
3434
import co.aurasphere.botmill.kik.model.MessageType;
@@ -153,7 +153,7 @@ public LinkMessageBuilder setAttribution(Attribution attribution) {
153153
* @return the link message builder
154154
*/
155155
public LinkMessageBuilder setDelay(Integer delay) {
156-
linkMessage.setDelay(String.valueOf(delay));
156+
linkMessage.setDelay(delay);
157157
return this;
158158
}
159159

src/main/java/co/aurasphere/botmill/kik/builder/PictureMessageBuilder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@
2525
*/
2626
package co.aurasphere.botmill.kik.builder;
2727

28-
import co.aurasphere.botmill.kik.configuration.Keyboard;
2928
import co.aurasphere.botmill.kik.model.BaseBuilder;
3029
import co.aurasphere.botmill.kik.model.Buildable;
30+
import co.aurasphere.botmill.kik.model.Keyboard;
3131
import co.aurasphere.botmill.kik.model.Keyboardable;
3232
import co.aurasphere.botmill.kik.model.MediaAttribution;
3333
import co.aurasphere.botmill.kik.model.MessageType;
@@ -98,7 +98,7 @@ public PictureMessageBuilder setPicUrl(String picUrl) {
9898
* @return the picture message builder
9999
*/
100100
public PictureMessageBuilder setDelay(Integer delay) {
101-
pictureMessage.setDelay(String.valueOf(delay));
101+
pictureMessage.setDelay(delay);
102102
return this;
103103
}
104104

0 commit comments

Comments
 (0)