Adding global timestamp option to messages.#242
Adding global timestamp option to messages.#242scr267 wants to merge 1 commit intoshazow:masterfrom scr267:timestampopt
Conversation
|
@za267 That's cool that you made a feature for your server. :) One thing to keep in mind is that history message replay will break the This isn't how I would implement this feature for our version of ssh-chat, but I hope it's working for you! If you're interested in implementing a feature to be merged, pleased open an issue to discuss design/requirements first. |
|
If you want a super quick-and-dirty way to add timestamps, you could prepend the current timestamp right before it gets sent to the user's screen in this function: https://github.com/shazow/ssh-chat/blob/master/chat/message/user.go#L168 |
|
Ah, good to know - I'll open a feature next time, possibly in the near future :) And I'll take a look at the function you point to on Line 168 of user.go. As you mention, I did notice that the timestamps were not quite accurate... meaning that the timestamp is generated during rendering instead of when it is actually sent. I was having a conundrum with that bit. Initially I wanted to see if it was possible to have a user option that could enable/disable timestamps. If the user entered /ts for example, it would trigger a boolean. Anyway it only partially worked because the prompts are sent in a different manner than the messages, and I absolutely needed both of these to have it. Ah well... back to the drawing board. Cheers! |
|
Messages already have a timestamp you can use, no need to make your own: https://github.com/shazow/ssh-chat/blob/master/chat/message/message.go#L14 |
|
I didn't notice it in the code... Do you think any of this code can be reused to add a timestamp to the prompts? |
|
Which code? From the PR? You're definitely welcome to use it for your server but I'd want a different approach to merge it in here. :) |
|
I'll test with the function you mention. I'm just wondering how I might add timestamps to the "prompt" line. EG: own messages. |
|
Ah, you'll need to update the prompt every minute or somesuch: https://github.com/shazow/ssh-chat/blob/master/host.go#L175 |
|
I'm going to open up a proper feature request... |
This is a feature that I needed - Quite simply when the server is started with the --timestamp flag, all messages including user prompts will have a timestamps added.