1-- spam_detector.lua
2-- Flags incoming emails that match common spam patterns.
3
4local matcha = require("matcha")
5
6local spam_patterns = {
7 "you have won",
8 "claim your prize",
9 "act now",
10 "limited time offer",
11 "click here immediately",
12 "congratulations!",
13 "urgent action required",
14 "unsubscribe",
15}
16
17matcha.on("email_received", function(email)
18 local subj = email.subject:lower()
19 for _, pattern in ipairs(spam_patterns) do
20 if subj:find(pattern, 1, true) then
21 matcha.notify("Possible spam: " .. email.subject, 3)
22 return
23 end
24 end
25end)