👨‍💻 dev AXFunnelResponder

development

owly

闇の伝説
Staff member
戦闘 コーダー
should be like the OG funnel, but with responders instead of string values
 

fukurou

the supreme coder
ADMIN
for the foot fuckin' skill right?
hmm... well if you gonna attach multiple riggers to the same responder...
that's a maybe
 

owly

闇の伝説
Staff member
戦闘 コーダー
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
 

fukurou

the supreme coder
ADMIN
Java:
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 "";
    }
}
 

owly

闇の伝説
Staff member
戦闘 コーダー
Python:
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 ""
 
Top