-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathInputPasswordScene.java
31 lines (24 loc) · 1.05 KB
/
InputPasswordScene.java
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
package com.greenapi.chatbot.examples.state;
import com.greenapi.chatbot.pkg.Scene;
import com.greenapi.chatbot.pkg.state.State;
import com.greenapi.client.pkg.models.notifications.MessageWebhook;
public class InputPasswordScene extends Scene {
@Override
public State processIncomingMessage(MessageWebhook incomingMessage, State currentState) {
var stateData = currentState.getData();
var password = getText(incomingMessage);
if (password.isPresent() && password.get().length() <= 20 && password.get().length() >= 8) {
stateData.put("password", password);
currentState.setData(stateData);
answerWithText(incomingMessage, String.format("""
Successful account creation.
Your username: %s.
Your password: %s.
""", stateData.get("username"), password));
return activateStartScene(currentState);
} else {
answerWithText(incomingMessage, "invalid password");
}
return currentState;
}
}