<commit_before>------------------------
--  Helper functions  --
------------------------

-- print key, value pairs of table
function print_pairs(table)
    for k, v in ipairs(table) do
        print(k, v)
    end
end

-- print 'from', 'to', 'subject' fields of matched results
function print_matched(results)
    for _, message in ipairs(results) do
        mailbox, uid = table.unpack(message)
        from = mailbox[uid]:fetch_field('from')
        to = mailbox[uid]:fetch_field('to')
        subject = mailbox[uid]:fetch_field('subject')
        print(_, from)
        print(_, to)
        print(_, subject)
    end
end


---------------
--  Options  --
---------------

options.timeout = 30
options.subscribe = true
options.info = true                 -- print summary of each action while processing mailboxes


-----------------
--  Passwords  --
-----------------

status, output = pipe_from('gpg --quiet --batch --use-agent --decrypt --output - ~/.config/mutt/password-gmx.gpg')
_, _, password_gmx = string.find(output, '([%w%p]+)')


----------------
--  Accounts  --
----------------

account_gmx = IMAP {
    server = 'imap.gmx.com',
    port = 993,
    username = '<EMAIL>',
    password = <PASSWORD>,
    ssl = '<PASSWORD>',
}

-- Get a list of the available mailboxes and folders
--mailboxes, folders = account_gmx:list_all()

-- print available mailboxes
--print_pairs(mailboxes)


-- create mailbox
--account_gmx:create_mailbox('aur-general')
--account_gmx:create_mailbox('arch-general')
--account_gmx:create_mailbox('arch-wiki')
--account_gmx:create_mailbox('arch')


---------------
--  Filters  --
---------------

function filter_gmx()
    -- Get the status of a mailbox
    account_gmx.INBOX:check_status()

    -- mark my own emails as read (sent back from mailing lists)
    unseen = account_gmx['INBOX']:is_unseen()
    results = unseen:contain_from('<EMAIL>')
    results:add_flags({ '\\Seen' })

    -- 'aur-general' mailbox
    messages = account_gmx['INBOX']
    results = messages:contain_to('<EMAIL>') +
              messages:contain_cc('<EMAIL>')
    results:move_messages(account_gmx['aur-general'])

    -- 'arch-general' mailbox
    messages = account_gmx['INBOX']
    results = messages:contain_to('<EMAIL>') +
              messages:contain_cc('<EMAIL>')
    results:move_messages(account_gmx['arch-general'])

    -- 'arch-wiki' mailbox
    messages = account_gmx['INBOX']
    results = messages:contain_from('<EMAIL>')
    results:move_messages(account_gmx['arch-wiki'])

    -- 'arch' mailbox
    messages = account_gmx['INBOX']
    results = messages:contain_from('<EMAIL>') + 
              messages:contain_from('<EMAIL>') + 
              messages:contain_from('<EMAIL>')
    results:move_messages(account_gmx['arch'])

    -- ArchWiki: Lahwaacz.bot edits
    messages = account_gmx['arch-wiki']:is_unseen()
    results = messages:contain_subject('changed by Lahwaacz.bot')
    results:add_flags({ '\\Seen' })

    -- Signoff reports
    unseen = account_gmx['aur-general']:is_unseen()
    results = unseen:contain_subject('Signoff report from')
    results:add_flags({ '\\Seen' })
end<commit_msg>update imapfilter config<commit_after>------------------------
--  Helper functions  --
------------------------

-- print key, value pairs of table
function print_pairs(table)
    for k, v in ipairs(table) do
        print(k, v)
    end
end

-- print 'from', 'to', 'subject' fields of matched results
function print_matched(results)
    for _, message in ipairs(results) do
        mailbox, uid = table.unpack(message)
        from = mailbox[uid]:fetch_field('from')
        to = mailbox[uid]:fetch_field('to')
        subject = mailbox[uid]:fetch_field('subject')
        print(_, from)
        print(_, to)
        print(_, subject)
    end
end


---------------
--  Options  --
---------------

options.timeout = 30
options.subscribe = true
options.info = true                 -- print summary of each action while processing mailboxes


-----------------
--  Passwords  --
-----------------

status, output = pipe_from('gpg --quiet --batch --use-agent --decrypt --output - ~/.config/mutt/password-gmx.gpg')
_, _, password_gmx = string.find(output, '([%w%p]+)')


----------------
--  Accounts  --
----------------

account_gmx = IMAP {
    server = 'imap.gmx.com',
    port = 993,
    username = '<EMAIL>',
    password = <PASSWORD>,
    ssl = '<PASSWORD>',
}

-- Get a list of the available mailboxes and folders
--mailboxes, folders = account_gmx:list_all()

-- print available mailboxes
--print_pairs(mailboxes)


-- create mailbox
--account_gmx:create_mailbox('aur-general')
--account_gmx:create_mailbox('arch-general')
--account_gmx:create_mailbox('arch-wiki')
--account_gmx:create_mailbox('arch')


---------------
--  Filters  --
---------------

function filter_gmx()
    -- Get the status of a mailbox
    account_gmx.INBOX:check_status()

    -- mark my own emails as read (sent back from mailing lists)
    unseen = account_gmx['INBOX']:is_unseen()
    results = unseen:contain_from('<EMAIL>')
    results:add_flags({ '\\Seen' })

    -- 'aur-general' mailbox
    messages = account_gmx['INBOX']
    results = messages:contain_to('<EMAIL>') +
              messages:contain_cc('<EMAIL>')
    results:move_messages(account_gmx['aur-general'])

    -- 'arch-general' mailbox
    messages = account_gmx['INBOX']
    results = messages:contain_to('<EMAIL>') +
              messages:contain_cc('<EMAIL>')
    results:move_messages(account_gmx['arch-general'])

    -- 'arch-wiki' mailbox
    messages = account_gmx['INBOX']
    results = messages:contain_from('<EMAIL>')
    results:move_messages(account_gmx['arch-wiki'])

    -- 'arch' mailbox
    messages = account_gmx['INBOX']
    results = messages:contain_from('<EMAIL>') + 
              messages:contain_from('<EMAIL>') + 
              messages:contain_from('<EMAIL>')
    results:move_messages(account_gmx['arch'])

    -- ArchWiki: Lahwaacz.bot edits
    messages = account_gmx['arch-wiki']:is_unseen()
    results = messages:contain_subject('changed by Lahwaacz.bot')
    results:add_flags({ '\\Seen' })

    -- Signoff reports
    unseen = account_gmx['aur-general']:is_unseen()
    results = unseen:contain_subject('Signoff report from')
    results:add_flags({ '\\Seen' })
end
{'fraction_non_alphanumeric': 0.19406066380816261, 'fraction_numerical': 0.001588057805304113, 'mean_word_length': 2.572319909245604, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1535405', 'n_tokens_mistral': 2029, 'n_tokens_neox': 1978, 'n_words': 395}