Open sjrct opened 5 years ago
To add to this, I'd like this kind of behavior represented somehow, either by transparent class, or something else:
match_agent("irc", "irc/##halibot") -> True
match_ri("irc/##halibot", "irc/##halibot") -> True
match_ri("irc", "irc/##halibot") -> False
ri("irc/##halibot").agents() -> "irc"
ri("irc/##halibot").modules() -> ""
ri("irc/##halibot").meta() -> "##halibot"
Largely tossing ideas out there, I don't have anything coherent in mind yet.
Here's another thought: maybe there should be a way to retrieve values from a dict based on an RI, and have it transparently apply any hierarchies:
{
"filters": {
"inbound": {
"irc": ["test"],
"irc/##halibot": ["foobar"]
}
}
}
get_filters(ri="irc/##halibot", childonly=True) # returns ["foobar"]
get_filters(ri="irc/##halibot", parentonly=True) # returns ["test"]
get_filters(ri="irc/##halibot") # returns ["foobar, "test"]
get_filters(ri="irc/##halibot", parentfirst=True) # returns [ "test", "foobar"]
RI logic right now is in various places throughout the code base. We split and join on
"/"
in a bunch of places. We really should have that and other RI-specific logic in an abstract layer. Could be a class that looks like a string, although maybe a module with functions that take strings to interpret as RIs are better.