that would be cumbersome.IG we don't need a default. but I wonder if it should be even limited to Responders,
I mean we have so many chatbot modules: Eliza, RailChatbot and so on
public class AXFunnelResponder {
private Map<String, Responder> dic;
public AXFunnelResponder() {
this.dic = new HashMap<>();
}
public AXFunnelResponder addKV(String key, Responder value) {
// add key-value pair
dic.put(key, value);
return this;
}
public String funnel(String key) {
if (dic.containsKey(key)){
return dic.get(key).getAResponse();
}
return key;
}
public String funnelOrNothing(String key) {
// get value from dictionary or return the key itself as default
if (dic.containsKey(key)){
return dic.get(key).getAResponse();
}
return "";
}
}
class AXFunnelResponder:
def __init__(self):
self.dic: Dict[str, Responder] = {}
def add_kv(self, key: str, value: Responder) -> AXFunnelResponder:
# Add key-value pair
self.dic[key] = value
return self
def funnel(self, key: str) -> str:
# Default funnel = key
if key in self.dic:
return self.dic[key].getAResponse()
return key
def funnel_or_nothing(self, key: str) -> str:
# Default funnel = ""
if key in self.dic:
return self.dic[key].getAResponse()
return ""