On 9/18/21 1:41 AM, Guillermo Hernandez (Oldno7) via Mailman-users wrote:
I've been trying to "translate" the python script that I made for mailman2 to new mailman3, but obviously, I'm missing something. It seems that mailman cannot locate the "module" needed.
The script is named "moderar.py":
*-*-*-*-*-*-*-*-*-* (begin of /usr/local/mailman3/moderar.py)
/usr/local/mailman3 # cat moderar.py #! /usr/local/bin/python3 # # script via withlist para moderar a pelo en mailman3 #
import os import sys
sys.path.insert(0, '/usr/local/mailman3')
If /usr/local/mailman3 is not already in the path, this is too late.
The rest of your script is not relevant.
Here's what you need:
from mailman.interfaces.action import Action def moderar(mlist, member): memb = mlist.members.get_member(member) if not memb: print('{} is not a list member.'.format(member)) return memb.moderation_action = Action.hold print('{} moderation_action set to hold.'.format(member))
That should be put in a moderar.py file somewhere in Mailman's path. The
same directory that contains the mailman
command is for sure good.
Possibly that's /usr/local/mailman3/bin/.
Then
mailman withlist -r moderar -l list_to_use@mydomain.com address@moderate.com
should work.
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan