Files
next.orly.dev/scripts/sprocket/test-sprocket-example.sh
mleku bae1d09f8d Add Sprocket Test Suite and Integration Scripts
This commit introduces a comprehensive test suite for the Sprocket integration, including various test scripts to validate functionality. Key additions include:

- `run-sprocket-test.sh`: An automated test runner for Sprocket integration tests.
- `SPROCKET_TEST_README.md`: Documentation detailing the test suite, criteria, and usage instructions.
- `test-sprocket-complete.sh`: A complete test suite that sets up the relay and runs all tests.
- `test-sprocket-manual.sh`: A manual testing script for interactive event testing.
- `test-sprocket-demo.sh`: A demonstration script showcasing Sprocket functionality.
- Additional test scripts for various scenarios, including normal events, spam detection, and blocked hashtags.

These changes enhance the testing framework for the Sprocket system, ensuring robust validation of event processing capabilities.
2025-10-09 19:33:42 +01:00

29 lines
939 B
Bash

#!/bin/bash
# Example sprocket script that demonstrates event processing
# This script reads JSON events from stdin and outputs JSONL responses
# Read events from stdin line by line
while IFS= read -r line; do
# Parse the event JSON
event_id=$(echo "$line" | jq -r '.id')
event_kind=$(echo "$line" | jq -r '.kind')
event_content=$(echo "$line" | jq -r '.content')
# Example policy: reject events with certain content
if [[ "$event_content" == *"spam"* ]]; then
echo "{\"id\":\"$event_id\",\"action\":\"reject\",\"msg\":\"content contains spam\"}"
continue
fi
# Example policy: shadow reject events from certain kinds
if [[ "$event_kind" == "9999" ]]; then
echo "{\"id\":\"$event_id\",\"action\":\"shadowReject\",\"msg\":\"\"}"
continue
fi
# Default: accept the event
echo "{\"id\":\"$event_id\",\"action\":\"accept\",\"msg\":\"\"}"
done