Refined apply conditions

This commit is contained in:
Lyncoln
2026-10-17 11:58:00 -04:00
parent 434d0408ee
commit 480ca9726b
8 changed files with 29 additions and 20 deletions
+19 -13
View File
@@ -1,26 +1,32 @@
def applyConditions(definition, outputs):
def applyConditions(definition, dictionary):
if hasattr(definition, "filters"):
print("DEBUG DICTIONARY PASS")
print(dictionary)
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 item[filter["filterkey"]] >= filter["filtervalue"]:
print("Applying filters")
if dictionary.get(filter["filterkey"]) >= filter["filtervalue"]:
print(filter["print"])
return True
if filter["operator"] == "<=":
if dictionary.get(filter["filterkey"]) <= filter["filtervalue"]:
print(filter["print"])
return True
if filter["operator"] == "==":
if item[filter["filterkey"]] == filter["filtervalue"]:
print("Applying filters")
if dictionary.get(filter["filterkey"]) == filter["filtervalue"]:
print(filter["print"])
return True
if filter["operator"] == "!=":
if dictionary.get(filter["filterkey"]) != filter["filtervalue"]:
print(filter["print"])
return True
if filter["operator"] == "in":
if filter["filtervalue"] in outputs[filter["filterkey"]]:
print("Applying filters")
if filter["filtervalue"] in dictionary:
print(filter["print"])
return True
return False
+5 -5
View File
@@ -25,14 +25,14 @@ def buildListener(listener, self):
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(item)
print(outputs["event"])
#print(item)
#print(outputs["event"])
if applyConditions(listener, outputs):
if applyConditions(listener, item):
continue
#if "state_key" in event:
+4 -1
View File
@@ -23,16 +23,19 @@ filters = [
"filterkey": "event",
"operator": "in",
"filtervalue": "state_key",
"print": "Excluding state.key event",
},
{
"filterkey": "sender",
"operator": "!=",
"filtervalue": "@lyncoln:loxthelion.com",
"print": "Excluding message loop item",
},
{
"filterkey": "type",
"operator": "==",
"operator": "!=",
"filtervalue": "m.room.message",
"print": "Excluding non-room message event",
},
]
Binary file not shown.
+1 -1
View File
@@ -1 +1 @@
{"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3OTIyNDQyMTEsIm5iZiI6MTc5MjI0NDAzMSwic3ViIjoiMjM4MzAyIiwidXNlcm5hbWUiOiJYeHhvdGlxIiwidXNlclR5cGUiOjEsInN0YWdlTmFtZSI6Ilh4eG90aXEiLCJhcHByb3ZlZCI6MSwibG9jYXRpb25JZCI6NDcyLCJzZWFyY2hDaXR5IjoiYXRsYW50YSIsImNvdW50cnlTaG9ydCI6IlVTIiwic2Vzc2lvbkNvdW50cnlDb250aW5lbnQiOiJOQSIsImlzRnJvemVuIjowLCJsb2NhdGlvbkxhYmVsIjoiQXRsYW50YSwgR0EiLCJpc3MiOiJodHRwczovL3JlbnRtYXNzZXVyLmNvbSIsImlhdCI6MTc5MjI0NDA5MX0.9dWUqLM3EYm68Dvk4_BzlEgbxJky8OtJtufM7S9MqOFF3gB3waVX9Q4usf4fbpy1BokDou8EJ4y3mR26PDrQnQ", "refresh_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3OTQ4MzYwOTEsIm5iZiI6MTc5MjI0NDAzMSwianRpIjoiUDNkY2JFeVRYRTBOc0tDTS9vNG5NMUtmRXVLdkdhNmlMRHBWS3AxSWQraz0iLCJpc3MiOiJodHRwczovL3JlbnRtYXNzZXVyLmNvbSIsImlhdCI6MTc5MjI0NDA5MSwic3ViIjoiMjM4MzAyIn0.ttcy40iHuhgVqXq1zgRre1Xxufs3m2auyKFTPsl9qHCFXIz6xixABmy4XEvTx5960qPlMtCtRiqOLWBf_-Bqcw"}
{"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3OTIyNTE0ODAsIm5iZiI6MTc5MjI1MTMwMCwic3ViIjoiMjM4MzAyIiwidXNlcm5hbWUiOiJYeHhvdGlxIiwidXNlcl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