Add intake-echo
This commit is contained in:
parent
d2195142dd
commit
e7e13ebc41
|
@ -39,3 +39,12 @@ Supported `env`:
|
||||||
- `FETCH_COUNT`: Number of posts to fetch from the front page. Default 30.
|
- `FETCH_COUNT`: Number of posts to fetch from the front page. Default 30.
|
||||||
- `REQUEST_RETRY`: Attempt count for fetching posts. Retries are done with exponential backoff.
|
- `REQUEST_RETRY`: Attempt count for fetching posts. Retries are done with exponential backoff.
|
||||||
- `MIN_SCORE`: Skip stories with scores below this number.
|
- `MIN_SCORE`: Skip stories with scores below this number.
|
||||||
|
|
||||||
|
## intake-echo
|
||||||
|
|
||||||
|
A feed source that echoes a message. This is useful with `cron` support to create recurring reminders.
|
||||||
|
|
||||||
|
Supported `env`:
|
||||||
|
- `TITLE`: The title of the item.
|
||||||
|
- `BODY`: The body of the item.
|
||||||
|
- `UNIQUE`: If set to a truthy value, the item id will be the hash of the title, so the same item will be generated until the message is changed.
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
});
|
});
|
||||||
in {
|
in {
|
||||||
default = pkgs.intakeSources;
|
default = pkgs.intakeSources;
|
||||||
inherit (pkgs) intake-rss intake-reddit intake-hackernews;
|
inherit (pkgs) intake-rss intake-reddit intake-hackernews intake-echo;
|
||||||
};
|
};
|
||||||
|
|
||||||
devShells.${system} = {
|
devShells.${system} = {
|
||||||
|
@ -44,11 +44,13 @@
|
||||||
final.intake-rss
|
final.intake-rss
|
||||||
final.intake-reddit
|
final.intake-reddit
|
||||||
final.intake-hackernews
|
final.intake-hackernews
|
||||||
|
final.intake-echo
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
intake-rss = pythonPackage "intake-rss" ./intake-rss [ final.python38Packages.feedparser ];
|
intake-rss = pythonPackage "intake-rss" ./intake-rss [ final.python38Packages.feedparser ];
|
||||||
intake-reddit = pythonPackage "intake-reddit" ./intake-reddit [];
|
intake-reddit = pythonPackage "intake-reddit" ./intake-reddit [];
|
||||||
intake-hackernews = pythonPackage "intake-hackernews" ./intake-hackernews [];
|
intake-hackernews = pythonPackage "intake-hackernews" ./intake-hackernews [];
|
||||||
|
intake-echo = pythonPackage "intake-echo" ./intake-echo [];
|
||||||
};
|
};
|
||||||
|
|
||||||
nixosModules.default = {
|
nixosModules.default = {
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
import sys
|
||||||
|
from .core import main
|
||||||
|
sys.exit(main())
|
|
@ -0,0 +1,22 @@
|
||||||
|
import hashlib
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
import random
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
item = {}
|
||||||
|
|
||||||
|
title = os.environ.get("TITLE", "Hello, world!")
|
||||||
|
|
||||||
|
if os.environ.get("UNIQUE"):
|
||||||
|
item["id"] = hashlib.md5(title.encode("utf8")).hexdigest()
|
||||||
|
else:
|
||||||
|
item["id"] = "{:x}".format(random.getrandbits(16 * 4))
|
||||||
|
|
||||||
|
item["title"] = title
|
||||||
|
|
||||||
|
if body := os.environ.get("BODY"):
|
||||||
|
item["body"] = body
|
||||||
|
|
||||||
|
print(json.dumps(item))
|
|
@ -0,0 +1,10 @@
|
||||||
|
[project]
|
||||||
|
name = "intake-echo"
|
||||||
|
version = "0.1.0"
|
||||||
|
|
||||||
|
[project.scripts]
|
||||||
|
intake-echo = "intake_echo.core:main"
|
||||||
|
|
||||||
|
[tool.setuptools]
|
||||||
|
packages = ["intake_echo"]
|
||||||
|
|
Loading…
Reference in New Issue