Added recursive action behavior to recursively go over selected messages

This commit is contained in:
Lyncoln
2026-10-14 18:28:06 -04:00
parent b4bb3b0c05
commit 3acd3fafc5
26 changed files with 44 additions and 104 deletions
Binary file not shown.
+1 -1
View File
@@ -22,7 +22,7 @@ def executeRequest(action, outputs, resolved):
# session.cookies.set( # session.cookies.set(
# sessioncookies[cookie_name] = response[cookie_key], # sessioncookies[cookie_name] = response[cookie_key],
print(request) #print(request)
#print(response.status_code) #print(response.status_code)
#print(response.text) #print(response.text)
return response, outputs return response, outputs
+11 -3
View File
@@ -3,10 +3,18 @@ from core.runtime.runtimecontract import buildRuntimeAttr, buildPreRuntimeAttr
def buildAction (action, outputs): def buildAction (action, outputs):
outputs, resolved = buildPreRuntimeAttr(action, outputs) #outputs, resolved = buildPreRuntimeAttr(action, outputs)
response, outputs = executeRequest(action, outputs, resolved) if hasattr(action, "recursive"):
for item in outputs[action.recursive["source"]]:
outputs[action.recursive["label"]] = item
outputs, resolved = buildPreRuntimeAttr(action, outputs)
response, outputs = executeRequest(action, outputs, resolved)
outputs, response = buildRuntimeAttr(action, outputs, response)
outputs, response = buildRuntimeAttr(action, outputs, response) else:
outputs, resolved = buildPreRuntimeAttr(action, outputs)
response, outputs = executeRequest(action, outputs, resolved)
outputs, response = buildRuntimeAttr(action, outputs, response)
return outputs, response return outputs, response
+2 -2
View File
@@ -2,7 +2,7 @@ import logging
from core.runtime.managefailure import manageFailure from core.runtime.managefailure import manageFailure
from core.execution.action.action import buildAction from core.execution.action.action import buildAction
from core.runtime.skipstep import skipStep from core.runtime.skipstep import skipStep
from core.runtime.recursiveactions import recursiveAction from core.runtime.recursive import recursiveSet
def buildOperation(definition): def buildOperation(definition):
actions = definition.actions actions = definition.actions
@@ -15,7 +15,7 @@ def buildOperation(definition):
continue continue
if action == "recursiveset": if action == "recursiveset":
outputs = recursiveAction(definition, outputs) outputs = recursiveSet(definition, outputs)
else: else:
outputs, response = buildAction(action, outputs) outputs, response = buildAction(action, outputs)
-1
View File
@@ -1 +0,0 @@
from . import manager
Binary file not shown.
Binary file not shown.
-25
View File
@@ -1,25 +0,0 @@
from datetime import datetime
from core.operation.operation import buildOperation
def buildManager(definition):
operations = definition.operations
current_time = datetime.now().time()
for operation in operations:
if hasattr(operation, "role") and operation.role == "activate":
if definition.uptime <= current_time <= definition.downtime:
while True:
current_time = datetime.now().time()
outputs = buildOperation(operation)
if hasattr(operation, "role") and operation.role == "deactivate":
if definition.downtime <= current_time <= definition.uptime:
while True:
current_time = datetime.now().time()
outputs = buildOperation(operation)
# if hasattr(operation, "role") and role == offline:
# outputs = buildOperation(operation)
Binary file not shown.
@@ -1,5 +1,20 @@
from core.execution.action.action import buildAction from core.execution.action.action import buildAction
def recursiveSet(definition, outputs):
recursiveset = definition.recursiveset["actions"]
for item in outputs[definition.recursiveset["source"]]:
outputs[definition.recursiveset["outputlabel"]] = item
#outputs["recursive"] = item
for job in recursiveset:
outputs, response = buildAction(job, outputs)
print(outputs["profile"])
print(outputs["messages"])
return outputs
from core.execution.action.action import buildAction
def recursiveAction(definition, outputs): def recursiveAction(definition, outputs):
recursiveset = definition.recursiveset["actions"] recursiveset = definition.recursiveset["actions"]
for item in outputs[definition.recursiveset["source"]]: for item in outputs[definition.recursiveset["source"]]:
@@ -12,4 +27,3 @@ def recursiveAction(definition, outputs):
print(outputs["profile"]) print(outputs["profile"])
print(outputs["messages"]) print(outputs["messages"])
return outputs return outputs
@@ -6,8 +6,6 @@ kind = "action"
showstatus = True showstatus = True
astoken = os.environ["AS_TOKEN"]
resolve = { resolve = {
"sender": ["messages", 0, "senderId"], "sender": ["messages", 0, "senderId"],
"space_id": ["space_id"], "space_id": ["space_id"],
@@ -25,11 +23,6 @@ keys = [
method = "PUT" method = "PUT"
#path = [
# "https://loxthelion.com/_matrix/client/v3/profile/rmass_",
# {"resolved": "sender"},
# {"suffix": "/displayname"},
#]
path = [ path = [
"https://loxthelion.com/_matrix/client/v3/rooms/", "https://loxthelion.com/_matrix/client/v3/rooms/",
{"resolved": "space_id"}, {"resolved": "space_id"},
@@ -46,6 +39,3 @@ headers = {
"Content-Type": "application/json", "Content-Type": "application/json",
} }
#outputs = {
# "user_id": "user_id",
#}
@@ -10,15 +10,9 @@ astoken = os.environ["AS_TOKEN"]
resolve = { resolve = {
"sender": ["messages", 0, "senderId"], "sender": ["messages", 0, "senderId"],
#"messageid": ["message", "id"],
"username": ["profile", "username"], "username": ["profile", "username"],
#"location": ["profile", "location"],
} }
keys = [ keys = [
#{
# "keytitle": "type",
# "keyvalue": "m.login.application_service",
#},
{ {
"keytitle": "displayname", "keytitle": "displayname",
"keyvalue": { "keyvalue": {
@@ -29,11 +23,6 @@ keys = [
method = "PUT" method = "PUT"
#path = [
# "https://loxthelion.com/_matrix/client/v3/profile/rmass_",
# {"resolved": "sender"},
# {"suffix": "/displayname"},
#]
path = [ path = [
"https://loxthelion.com/_matrix/client/v3/profile/@rmass_", "https://loxthelion.com/_matrix/client/v3/profile/@rmass_",
{"resolved": "sender"}, {"resolved": "sender"},
@@ -50,6 +39,3 @@ headers = {
"Content-Type": "application/json", "Content-Type": "application/json",
} }
#outputs = {
# "user_id": "user_id",
#}
+1 -4
View File
@@ -6,14 +6,11 @@ kind = "action"
showstatus = True showstatus = True
astoken = os.environ["AS_TOKEN"]
resolve = { resolve = {
"sender": ["messages", 0, "senderId"], "sender": ["messages", 0, "senderId"],
#"messageid": ["message", "id"],
"username": ["profile", "username"], "username": ["profile", "username"],
#"location": ["profile", "location"],
} }
keys = [ keys = [
{ {
"keytitle": "name", "keytitle": "name",
+12 -6
View File
@@ -6,13 +6,17 @@ kind = "action"
showstatus = True showstatus = True
recursive = {
"source": "messages",
"label": "messageitem",
}
resolve = { resolve = {
"sender": ["messages", 0, "senderId"], "sender": ["messageitem", "senderId"],
"message_id": ["messages", 0, "id"], "message_id": ["messageitem", "id"],
#"username": ["profile", "username"], "message_body": ["messageitem", "text"],
"message_body": ["messages", 0, "text"],
"room_id": ["dmroom_id"], "room_id": ["dmroom_id"],
#"location": ["profile", "location"], "timestamp": ["messageitem", "createdAt"],
} }
keys = [ keys = [
{ {
@@ -36,7 +40,9 @@ path = [
{"resolved": "message_id"}, {"resolved": "message_id"},
"?user_id=@rmass_", "?user_id=@rmass_",
{"resolved": "sender"}, {"resolved": "sender"},
":loxthelion.com", ":loxthelion.com&ts=",
{"resolved": "timestamp"},
"000"
] ]
headers = { headers = {
-4
View File
@@ -6,13 +6,9 @@ kind = "action"
showstatus = True showstatus = True
astoken = os.environ["AS_TOKEN"]
resolve = { resolve = {
"sender": ["messages", 0, "senderId"], "sender": ["messages", 0, "senderId"],
#"messageid": ["message", "id"],
"username": ["profile", "username"], "username": ["profile", "username"],
#"location": ["profile", "location"],
} }
keys = [ keys = [
{ {
-24
View File
@@ -1,24 +0,0 @@
import os
from datetime import datetime
from . import setavailableoperation
operations = [
setavailableoperation,
#setunavailableoperation
#setnotsetoperation
]
uptime = datetime.strptime(
os.environ["TIME_UPTIME"],
"%H:%M"
).time
downtime = datetime.strptime(
os.environ["TIME_UPTIME"],
"%H:%M"
).time
offline = datetime.strptime(
os.environ["TIME_OFFLINE"],
"%H:%M"
).time
@@ -1,7 +0,0 @@
from . import getcsrf, login, checkavailability
actions = [
getcsrf,
login,
checkavailability,
]
+1 -1
View File
@@ -1 +1 @@
{"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3OTIwMTA1MDUsIm5iZiI6MTc5MjAxMDMyNSwic3ViIjoiMjM4MzAyIiwidXNlcm5hbWUiOiJYeHhvdGlxIiwidXNlclR5cGUiOjEsInN0YWdlTmFtZSI6Ilh4eG90aXEiLCJhcHByb3ZlZCI6MSwibG9jYXRpb25JZCI6NDcyLCJzZWFyY2hDaXR5IjoiYXRsYW50YSIsImNvdW50cnlTaG9ydCI6IlVTIiwic2Vzc2lvbkNvdW50cnlDb250aW5lbnQiOiJOQSIsImlzRnJvemVuIjowLCJsb2NhdGlvbkxhYmVsIjoiQXRsYW50YSwg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