diff options
| author | Rapptz <[email protected]> | 2015-09-04 22:00:22 -0400 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2015-09-04 22:00:22 -0400 |
| commit | b4e6591c9dd41fd7f30a2be101561d6d8b65bd8a (patch) | |
| tree | b0cd46064c8e80311f9507d09fd1fffe16274d32 /discord/message.py | |
| parent | Use kwargs if the number of arguments needed is too many. (diff) | |
| download | discord.py-b4e6591c9dd41fd7f30a2be101561d6d8b65bd8a.tar.xz discord.py-b4e6591c9dd41fd7f30a2be101561d6d8b65bd8a.zip | |
Refactor parse_time into its own utils file.
Diffstat (limited to 'discord/message.py')
| -rw-r--r-- | discord/message.py | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/discord/message.py b/discord/message.py index 5fe871cd..01dbc37e 100644 --- a/discord/message.py +++ b/discord/message.py @@ -24,8 +24,7 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ -import datetime -import re +from .utils import parse_time from .user import User class Message(object): @@ -75,11 +74,8 @@ class Message(object): # we can use this to our advantage to use strptime instead of a complicated parsing routine. # example timestamp: 2015-08-21T12:03:45.782000+00:00 # sometimes the .%f modifier is missing - self.edited_timestamp = kwargs.get('edited_timestamp') - if self.edited_timestamp is not None: - self.edited_timestamp = self._parse_time(edited_timestamp) - - self.timestamp = self._parse_time(kwargs.get('timestamp')) + self.edited_timestamp = parse_time(kwargs.get('edited_timestamp')) + self.timestamp = parse_time(kwargs.get('timestamp')) self.tts = kwargs.get('tts') self.content = kwargs.get('content') self.mention_everyone = kwargs.get('mention_everyone') @@ -90,6 +86,3 @@ class Message(object): self.mentions = [User(**mention) for mention in kwargs.get('mentions', {})] self.attachments = kwargs.get('attachments') - def _parse_time(self, time_string): - return datetime.datetime(*map(int, re.split(r'[^\d]', time_string.replace('+00:00', '')))) - |