archangelic / pinhook

the pluggable python framework for IRC bots and Twitch bots
https://archangelic.github.io/pinhook/
MIT License
31 stars 4 forks source link

Add timestamp to Message object #43

Closed RussellChamp closed 5 years ago

RussellChamp commented 5 years ago

Add timestamp to the Message object that gets passed to plugin handlers and listeners

archangelic commented 5 years ago

So there are several options for this, we could have a formatted string, a datetime.datetime object, or just a unix timestamp. Any preferences?

Lucidiot commented 5 years ago

a datetime object sounds more Pythonic and would be better to manage any kinds of services, no matter what they output. To convert to a single formatted string you would probably need to use a datetime to parse it at some point so that would be simpler

RussellChamp commented 5 years ago

I would honestly prefer a unix timestamp (similar to what we see in chat logs) as that's what I use persisting certain things in my own bot logs. I also prefer to use inflect to parse and display the time so I would have to parse it back into a timestamp if I wasn't provided one. Would there be any reason to not provide both datetime and timestamp?

archangelic commented 5 years ago

There wouldn't be any technical limitation to that, no. These are just additional attributes in the object.

archangelic commented 5 years ago

Going to go with datetime.now(timezone.utc) for the msg.datetime and a float of the unix timestamp for msg.timestamp. That work?