commit df15fc4980546e35313cac68dabf032be64a7a38 Author: Glenn Date: Tue Dec 19 16:06:14 2023 +0100 Initial import diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7a7d0ea --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ + +bin diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..d29d861 --- /dev/null +++ b/Makefile @@ -0,0 +1,6 @@ + +all: build + +build: + shards build + diff --git a/shard.yml b/shard.yml new file mode 100644 index 0000000..c88a796 --- /dev/null +++ b/shard.yml @@ -0,0 +1,23 @@ +name: signalspam-pipe +version: 0.1.0 + +targets: + signalspam-pipe: + main: src/main.cr + +# authors: +# - name + +# description: | +# Short description of signalspam-pipe + +# dependencies: +# pg: +# github: will/crystal-pg +# version: "~> 0.5" + +# development_dependencies: +# webmock: +# github: manastech/webmock.cr + +# license: MIT diff --git a/src/config.cr b/src/config.cr new file mode 100644 index 0000000..1d1878a --- /dev/null +++ b/src/config.cr @@ -0,0 +1,17 @@ + +class Config + include YAML::Serializable + + class Authentication + include YAML::Serializable + + @[YAML::Field(key: "username")] + property username : String + + @[YAML::Field(key: "password")] + property password : String + end + + @[YAML::Field(key: "authentication")] + property auth : Authentication +end diff --git a/src/main.cr b/src/main.cr new file mode 100644 index 0000000..5c98102 --- /dev/null +++ b/src/main.cr @@ -0,0 +1,32 @@ +require "yaml" +require "http/client" +require "./config.cr" +require "./version.cr" + +# Partie 1: Lecture du fichier de configuration YAML +config_path = File.expand_path("~/.config/signalspam/config.yaml", home: ENV["HOME"]) +begin + config = Config.from_yaml(File.read(config_path)) +rescue ex + puts "Error reading or parsing config file: #{ex.message}" + exit(1) +end + +# Partie 2: Lecture de l'email-spam depuis STDIN +email_spam = STDIN.gets_to_end + +# Partie 3: Authentification sur signal-spam.fr +def authenticate(config : Config) + # Logique d'authentification (à compléter) +end + +# Partie 4: Remplissage et envoi du formulaire +def submit_spam_report(email_spam : String, config : Config) + # Logique pour remplir et envoyer le formulaire (à compléter) +end + +# Exécution des fonctions +authenticate(config) +submit_spam_report(email_spam, config) + +puts "#{SCRIPT_NAME} v#{SCRIPT_VERSION} executed successfully." diff --git a/src/version.cr b/src/version.cr new file mode 100644 index 0000000..e8b96f0 --- /dev/null +++ b/src/version.cr @@ -0,0 +1,4 @@ + +# Nom du script et version +SCRIPT_NAME = "SignalSpamReporter" +SCRIPT_VERSION = "1.2"