Gnus development mailing list
 help / color / mirror / Atom feed
From: Emanuel Berg <moasenwood@zoho.eu>
To: ding@gnus.org
Subject: local ML with Gnus
Date: Thu, 28 Nov 2019 05:46:09 +0100	[thread overview]
Message-ID: <86imn41ucu.fsf@zoho.eu> (raw)

I think (?) I have succeed in writing software
for a local mailing list based on Gnus!
The code is hopefully understandable just be
reading...

Please help out to improve it tho, if you see
something. Problems that I've already detected
are indicated with comments.

The main style problem is of course that I do
this as a human would, only that is all
automated. While that seems to work fine, one
would wish it to be on the all-computer side of
things, in particular it would execute entirely
in the background.

That's probably not that difficult to do if you
know the right functions... so yeah, that can
be improved :)

File: https://dataswamp.org/~incal/emacs-init/gnus/mail-to-many.el

;;; -*- lexical-binding: t -*-

;; This file: http://user.it.uu.se/~embe8573/emacs-init/gnus/mail-to-many.el
;;            https://dataswamp.org/~incal/emacs-init/gnus/mail-to-many.el

;; Check out:
;;     http://user.it.uu.se/~embe8573/emacs-init/gnus/mailrc.el

(require 'cl-lib)
(require 'gnus-art)
(require 'gnus-msg)
(require 'gnus-sum)
(require 'message)

(defvar mtm-source-group)
(setq mtm-source-group "nnml:mail.obi-one")

(defvar mtm-test-receivers)
(setq mtm-test-receivers '(
                           "JH1 <joehacker1@lam.er>"
                           "JH2 <joehacker2@lam.er>"
                           "JH3 <joehacker3@lam.er>"
                           ))

(defun mtm-test ()
  (interactive)
  (mtm-send-random-article-to-list
   mtm-source-group
   mtm-test-receivers) )
;; (mtm-test)

(defun mtm-send-random-article-to-list (group list)
  (save-window-excursion ; still, annoying buffer flash-by
    (mtm-open-group group)
    (gnus-summary-goto-random-article)
    (gnus-summary-select-article-buffer)
    (let ((body    (gnus-article-get-body))
          (subject (gnus-fetch-field "Subject")) ; must be include in `gnus-visible-headers'
          )
      (send-mail-to-many list subject body) )))

(defun mtm-open-group (group)
  (gnus-group-read-group nil nil group) )

(defun gnus-summary-goto-random-article ()
  (interactive)
  (let*((ids             gnus-newsgroup-articles)
        (article-count   (length ids) )
        (random-position (random article-count))
        (article         (nth random-position ids)) )
    (gnus-summary-goto-article article) ))

(defun gnus-article-get-body ()
  (when (article-goto-body)
    (buffer-substring-no-properties (point) (point-max)) ))

;; TODO: delete mail

(defun send-mail-to-many (to-list subject body)
  (cl-dolist (to to-list)
    (send-mail-to to subject body) ))

(defun send-mail-to (to subject body)
  (gnus-post-news 'post "")
  (message-goto-to)       (insert to)
  (message-goto-subject)  (insert subject)
  (message-goto-body)     (insert body)
  (message-send-and-exit) )

(provide 'mail-to-many)

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal




             reply	other threads:[~2019-11-28  4:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-28  4:46 Emanuel Berg [this message]
2019-11-29  0:21 ` Eric Abrahamsen
2019-11-29  1:59   ` Emanuel Berg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86imn41ucu.fsf@zoho.eu \
    --to=moasenwood@zoho.eu \
    --cc=ding@gnus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).