1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
# Copyright (C) 2009-2014 by the Free Software Foundation, Inc.
#
# This file is part of GNU Mailman.
#
# GNU Mailman is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option)
# any later version.
#
# GNU Mailman is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along with
# GNU Mailman. If not, see <http://www.gnu.org/licenses/>.
"""Autoresponder."""
__all__ = [
'ALWAYS_REPLY',
'IAutoResponseRecord',
'IAutoResponseSet',
'Response',
'ResponseAction',
]
from datetime import timedelta
from enum import Enum
from zope.interface import Interface, Attribute
ALWAYS_REPLY = timedelta()
class Response(Enum):
# Your message was held for approval.
hold = 1
# Email commands, i.e. -request messages.
command = 2
# Messages to the list owner/administrator.
owner = 3
# Messages to the list's posting address.
postings = 4
class ResponseAction(Enum):
# No automatic response.
none = 0
# Respond, but discard the original message.
respond_and_discard = 1
# Respond and continue processing the message.
respond_and_continue = 2
class IAutoResponseRecord(Interface):
"""An auto-response record.
Every time Mailman sends an automatic response to an address, on a
specific mailing list for a specific purpose, it records the response. To
limit the effects of blow back and other third party spam, Mailman will
only send a certain number of such automatic response per day. After the
maximum is reached, it will not send another such response to the same
address until the next day.
"""
address = Attribute("""The email address being sent the auto-response.""")
mailing_list = Attribute(
"""The mailing list sending the auto-response.""")
response_type = Attribute("""The type of response sent.""")
class IAutoResponseSet(Interface):
"""Matching and setting auto-responses.
The `IAutoResponseSet` is contexted to a particular mailing list.
"""
def todays_count(address, response_type):
"""The number of responses sent to an address today.
:param address: The address who is the recipient of the auto-response.
:type address: `IAddress`
:param response_type: The response type being sent.
:type response_type: `Response`
:return: The number of auto-responses already received by the user
today, of this type, from this mailing list.
:rtype: int
"""
def response_sent(address, response_type):
"""Record the fact that another response is being sent to the address.
:param address: The address who is the recipient of the auto-response.
:type address: `IAddress`
:param response_type: The response type being sent.
:type response_type: `Response`
"""
def last_response(address, response_type):
"""Record the fact that another response is being sent to the address.
:param address: The address who is the recipient of the auto-response.
:type address: `IAddress`
:param response_type: The response type being sent.
:type response_type: `Response`
:return: the last response recorded.
:rtype: `IAutoResponseRecord`
"""
|