Initial import

This commit is contained in:
Glenn Y. Rolland 2023-12-19 16:06:14 +01:00
commit df15fc4980
6 changed files with 84 additions and 0 deletions

2
.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
bin

6
Makefile Normal file
View file

@ -0,0 +1,6 @@
all: build
build:
shards build

23
shard.yml Normal file
View file

@ -0,0 +1,23 @@
name: signalspam-pipe
version: 0.1.0
targets:
signalspam-pipe:
main: src/main.cr
# authors:
# - name <email@example.com>
# description: |
# Short description of signalspam-pipe
# dependencies:
# pg:
# github: will/crystal-pg
# version: "~> 0.5"
# development_dependencies:
# webmock:
# github: manastech/webmock.cr
# license: MIT

17
src/config.cr Normal file
View file

@ -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

32
src/main.cr Normal file
View file

@ -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."

4
src/version.cr Normal file
View file

@ -0,0 +1,4 @@
# Nom du script et version
SCRIPT_NAME = "SignalSpamReporter"
SCRIPT_VERSION = "1.2"