make packaging easier in nixland
This commit is contained in:
parent
55c6f3a5f8
commit
71bbd86d98
|
@ -1,2 +1,3 @@
|
|||
__pycache__/
|
||||
config.json
|
||||
config.json
|
||||
result
|
|
@ -0,0 +1,2 @@
|
|||
{ pkgs ? import <nixpkgs> {} }:
|
||||
pkgs.callPackage ./derivation.nix {}
|
|
@ -0,0 +1,10 @@
|
|||
{ lib, python3Packages }:
|
||||
with python3Packages;
|
||||
buildPythonApplication {
|
||||
pname = "groupme_sync";
|
||||
version = "1.0";
|
||||
|
||||
propagatedBuildInputs = [ websockets requests ];
|
||||
|
||||
src = ./.;
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
from sys import argv
|
||||
import json
|
||||
|
||||
from .groupme import GroupMe
|
||||
from .emailwrap import send_email
|
||||
|
||||
def main() -> None:
|
||||
filename = argv[1]
|
||||
with open(filename, "r") as file:
|
||||
data = json.loads(file.read())
|
||||
|
||||
chats = GroupMe(data["token"])
|
||||
for message in chats:
|
||||
title = "[GroupMe] {} sent a message in {}".format(message["name"], message["group_name"])
|
||||
body = """
|
||||
Greetings,
|
||||
|
||||
{} sent a message in group {} -- it reads as follows:
|
||||
|
||||
{}
|
||||
|
||||
Much regards,
|
||||
the internal beepboop.systems mail system
|
||||
""".format(
|
||||
message["name"],
|
||||
message["group_name"],
|
||||
message["text"]
|
||||
)
|
||||
|
||||
send_email(
|
||||
title=title,
|
||||
body=body,
|
||||
smtp_server=data["smtp_server"],
|
||||
smtp_username=data["smtp_username"],
|
||||
smtp_password=data["smtp_password"],
|
||||
from_addr=data["from_addr"],
|
||||
to_addr=data["to_addr"],
|
||||
)
|
||||
print(message)
|
|
@ -1,41 +1,4 @@
|
|||
from sys import argv
|
||||
import json
|
||||
from . import main
|
||||
|
||||
from .groupme import GroupMe
|
||||
from .emailwrap import send_email
|
||||
|
||||
def main() -> None:
|
||||
filename = argv[1]
|
||||
with open(filename, "r") as file:
|
||||
data = json.loads(file.read())
|
||||
|
||||
chats = GroupMe(data["token"])
|
||||
for message in chats:
|
||||
title = "[GroupMe] {} sent a message in {}".format(message["name"], message["group_name"])
|
||||
body = """
|
||||
Greetings,
|
||||
|
||||
{} sent a message in group {} -- it reads as follows:
|
||||
|
||||
{}
|
||||
|
||||
Much regards,
|
||||
the internal beepboop.systems mail system
|
||||
""".format(
|
||||
message["name"],
|
||||
message["group_name"],
|
||||
message["text"]
|
||||
)
|
||||
|
||||
send_email(
|
||||
title=title,
|
||||
body=body,
|
||||
smtp_server=data["smtp_server"],
|
||||
smtp_username=data["smtp_username"],
|
||||
smtp_password=data["smtp_password"],
|
||||
from_addr=data["from_addr"],
|
||||
to_addr=data["to_addr"],
|
||||
)
|
||||
print(message)
|
||||
|
||||
main()
|
||||
if __name__ == "__main__":
|
||||
main()
|
Loading…
Reference in New Issue