Refined apply conditions
This commit is contained in:
Binary file not shown.
@@ -1,26 +1,32 @@
|
|||||||
def applyConditions(definition, outputs):
|
def applyConditions(definition, dictionary):
|
||||||
if hasattr(definition, "filters"):
|
if hasattr(definition, "filters"):
|
||||||
|
print("DEBUG DICTIONARY PASS")
|
||||||
|
print(dictionary)
|
||||||
for filter in definition.filters:
|
for filter in definition.filters:
|
||||||
print("DEBUG applyConditons filter item consumption")
|
|
||||||
print(outputs["event"])
|
|
||||||
|
|
||||||
item = outputs["event"]
|
|
||||||
|
|
||||||
#current_value = item[filter["filterkey"]]
|
|
||||||
|
|
||||||
if filter["operator"] == ">=":
|
if filter["operator"] == ">=":
|
||||||
if item[filter["filterkey"]] >= filter["filtervalue"]:
|
if dictionary.get(filter["filterkey"]) >= filter["filtervalue"]:
|
||||||
print("Applying filters")
|
print(filter["print"])
|
||||||
|
return True
|
||||||
|
|
||||||
|
if filter["operator"] == "<=":
|
||||||
|
if dictionary.get(filter["filterkey"]) <= filter["filtervalue"]:
|
||||||
|
print(filter["print"])
|
||||||
return True
|
return True
|
||||||
|
|
||||||
if filter["operator"] == "==":
|
if filter["operator"] == "==":
|
||||||
if item[filter["filterkey"]] == filter["filtervalue"]:
|
if dictionary.get(filter["filterkey"]) == filter["filtervalue"]:
|
||||||
print("Applying filters")
|
print(filter["print"])
|
||||||
|
return True
|
||||||
|
|
||||||
|
if filter["operator"] == "!=":
|
||||||
|
if dictionary.get(filter["filterkey"]) != filter["filtervalue"]:
|
||||||
|
print(filter["print"])
|
||||||
return True
|
return True
|
||||||
|
|
||||||
if filter["operator"] == "in":
|
if filter["operator"] == "in":
|
||||||
if filter["filtervalue"] in outputs[filter["filterkey"]]:
|
if filter["filtervalue"] in dictionary:
|
||||||
print("Applying filters")
|
print(filter["print"])
|
||||||
return True
|
return True
|
||||||
|
|
||||||
return False
|
return False
|
||||||
Binary file not shown.
@@ -25,14 +25,14 @@ def buildListener(listener, self):
|
|||||||
|
|
||||||
|
|
||||||
for item in outputs[listener.recursive["source"]]:
|
for item in outputs[listener.recursive["source"]]:
|
||||||
outputs[listener.recursive["label"]] = item
|
#outputs[listener.recursive["label"]] = item
|
||||||
|
|
||||||
print("DEBUG item selection")
|
#print("DEBUG item selection")
|
||||||
#print(listener.recursive["label"])
|
#print(listener.recursive["label"])
|
||||||
print(item)
|
#print(item)
|
||||||
print(outputs["event"])
|
#print(outputs["event"])
|
||||||
|
|
||||||
if applyConditions(listener, outputs):
|
if applyConditions(listener, item):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
#if "state_key" in event:
|
#if "state_key" in event:
|
||||||
|
|||||||
Binary file not shown.
@@ -23,16 +23,19 @@ filters = [
|
|||||||
"filterkey": "event",
|
"filterkey": "event",
|
||||||
"operator": "in",
|
"operator": "in",
|
||||||
"filtervalue": "state_key",
|
"filtervalue": "state_key",
|
||||||
|
"print": "Excluding state.key event",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filterkey": "sender",
|
"filterkey": "sender",
|
||||||
"operator": "!=",
|
"operator": "!=",
|
||||||
"filtervalue": "@lyncoln:loxthelion.com",
|
"filtervalue": "@lyncoln:loxthelion.com",
|
||||||
|
"print": "Excluding message loop item",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filterkey": "type",
|
"filterkey": "type",
|
||||||
"operator": "==",
|
"operator": "!=",
|
||||||
"filtervalue": "m.room.message",
|
"filtervalue": "m.room.message",
|
||||||
|
"print": "Excluding non-room message event",
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
@@ -1 +1 @@
|
|||||||
{"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3OTIyNDQyMTEsIm5iZiI6MTc5MjI0NDAzMSwic3ViIjoiMjM4MzAyIiwidXNlcm5hbWUiOiJYeHhvdGlxIiwidXNlclR5cGUiOjEsInN0YWdlTmFtZSI6Ilh4eG90aXEiLCJhcHByb3ZlZCI6MSwibG9j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