2
# vim: ai ts=4 sts=4 et sw=4
9
class IncomingMessage(object):
10
def __init__(self, device, sender, sent, text):
12
# move the arguments into "private" attrs,
13
# to try to prevent from from being modified
19
# assume that the message was
20
# received right now, since we
21
# don't have an incoming buffer
22
self._received = datetime.datetime.utcnow().replace(tzinfo=pytz.utc)
26
return "<pygsm.IncomingMessage from %s: %r>" %\
27
(self.sender, self.text)
30
def respond(self, text):
31
"""Responds to this IncomingMessage by sending a message containing
32
_text_ back to the sender via the modem that created this object."""
33
return self.device.send_sms(self.sender, text)
38
"""Returns the pygsm.GsmModem device which received
39
the SMS, and created this IncomingMessage object."""
44
"""Returns the phone number of the originator of this IncomingMessage.
45
It is stored directly as reported by the modem, so no assumptions
46
can be made about it's format."""
51
"""Returns a datetime object containing the date and time that this
52
IncomingMessage was sent, as reported by the modem. Sometimes, a
53
network or modem will not report this field, so it will be None."""
58
"""Returns the text contents of this IncomingMessage. It will usually
59
be 160 characters or less, by virtue of being an SMS, but multipart
60
messages can, technically, be up to 39015 characters long."""
65
"""Returns a datetime object containing the date and time that this
66
IncomingMessage was created, which is a close aproximation of when
67
the SMS was received."""