Initial commit.
This commit is contained in:
commit
e83d6e4de9
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2022 Julien Palard
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
|
@ -0,0 +1,12 @@
|
|||
# Report to signal-spam.fr
|
||||
|
||||
## Install
|
||||
|
||||
To install signal-spam CLI, use:
|
||||
|
||||
python -m pip install signal-spam
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
signal-spam BuyMyDogFood.eml
|
|
@ -0,0 +1,32 @@
|
|||
[build-system]
|
||||
requires = ["setuptools", "wheel"]
|
||||
build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "signal-spam"
|
||||
description = "Report an eml file to signal-spam.fr"
|
||||
readme = "README.md"
|
||||
license = {text = "MIT License"}
|
||||
authors = [
|
||||
{name = "Julien Palard", email = "julien@palard.fr"},
|
||||
]
|
||||
requires-python = ">= 3.7"
|
||||
dependencies = [
|
||||
"requests"
|
||||
]
|
||||
dynamic = ["version"]
|
||||
|
||||
[project.urls]
|
||||
homepage = "https://git.afpy.org/mdk/signal-spam"
|
||||
|
||||
[project.scripts]
|
||||
signal-spam = "signalspam:main"
|
||||
|
||||
[tool.setuptools]
|
||||
py-modules = [
|
||||
"signalspam",
|
||||
]
|
||||
include-package-data = false
|
||||
|
||||
[tool.setuptools.dynamic.version]
|
||||
attr = "signalspam.__version__"
|
|
@ -0,0 +1,42 @@
|
|||
"""Send .eml files to signal-spam.fr."""
|
||||
|
||||
from base64 import b64encode
|
||||
from pathlib import Path
|
||||
from getpass import getpass
|
||||
import argparse
|
||||
|
||||
import requests
|
||||
|
||||
__version__ = "0.1"
|
||||
|
||||
|
||||
CONF = Path("~/.signal-spam").expanduser()
|
||||
|
||||
|
||||
def parse_args():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("eml", type=Path, help="An email file to report as spam.")
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
def main():
|
||||
args = parse_args()
|
||||
try:
|
||||
username, password = CONF.read_text(encoding="UTF-8").splitlines()
|
||||
except FileNotFoundError:
|
||||
username = input("signal spam username: ")
|
||||
password = getpass("signal spam password: ")
|
||||
CONF.write_text(f"{username}\n{password}\n", encoding='UTF-8')
|
||||
CONF.chmod(0o600)
|
||||
payload = {"dossier": 0, "message": b64encode(args.eml.read_text(encoding="UTF-8").encode("UTF-8"))}
|
||||
response = requests.post(
|
||||
"https://www.signal-spam.fr/api/signaler",
|
||||
auth=(username, password),
|
||||
timeout=10,
|
||||
data=payload)
|
||||
print("Sent")
|
||||
print(response.text)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
Loading…
Reference in New Issue