diff --git a/src/DustedCodes/Messages.fs b/src/DustedCodes/Messages.fs index 5ddd5c9..2805d13 100644 --- a/src/DustedCodes/Messages.fs +++ b/src/DustedCodes/Messages.fs @@ -7,6 +7,15 @@ module Messages = open System.Threading open System.Threading.Tasks + let private containsSpam (str : string) = + [ + "XEVIL 5" + "captchas solving" + "captcha solving" + ] + |> List.map (fun s -> s.ToLower()) + |> List.exists (str.ToLower().Contains) + [] type Request = { @@ -39,11 +48,16 @@ module Messages = Message = "" } + member this.IsSpam = + containsSpam this.Subject + || containsSpam this.Message + member this.IsValid = if String.IsNullOrEmpty this.Name then Error "Name cannot be empty." else if String.IsNullOrEmpty this.Email then Error "Email address cannot be empty." else if String.IsNullOrEmpty this.Subject then Error "Subject cannot be empty." else if String.IsNullOrEmpty this.Message then Error "Message cannot be empty." + else if this.IsSpam then Error "Cannot process this message" else Ok () member this.ToRequest @@ -89,4 +103,4 @@ module Messages = | Error err -> log Level.Error (sprintf "Failed to send message to MailDrop: %s" err) Error "Message could not be saved. Please try again later." - } \ No newline at end of file + }