Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Plugins ➜ Showing the time for each chat message

Showing the time for each chat message

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Nick Gammon   Australia  (23,165 posts)  Bio   Forum Administrator
Date Thu 17 Apr 2003 11:18 PM (UTC)

Amended on Thu 17 Apr 2003 11:20 PM (UTC) by Nick Gammon

Message
The flexibility of the chat system can be demonstrated with a minor change to the supplied "chat" plugin. Say you are chatting with people and want to know *when* a particular message arrived. You can modify the OnPluginChatDisplay callback function to add the date and/or time to each message.

The example below puts the time at the start of the message, and then uses ChatNote to redisplay it with the date. However, the program would quickly go into an infinite loop without one more check. We assign a user-assigned "message type" of 1000, which represents our modified message. When ChatNote calls OnPluginChatDisplay a second time, we detect the message type of 1000, and decline to redisplay it a second time.


Function OnPluginChatDisplay (message, sText)

  OnPluginChatDisplay = vbTrue  ' display it

  If message <> 1000 Then
    ChatNote 1000,  FormatDateTime (Now, vbShortTime) & ": " & sText
    OnPluginChatDisplay = vbFalse
  End If  
  
End Function


With this modification in place, you can now see this sort of thing:


#chat bruce aha
08:09: You chat to Bruce, 'aha'


Note the time at the start of the message.

Instead of "vbShortTime" in the code you can use one of the following:



  • vbGeneralDate - General date/time, eg. 18/04/03 8:17:39
  • vbLongDate - Long date, eg. Friday, 18 April 2003
  • vbShortDate - Short date, eg. 18/04/03 (Australian format)
  • vbLongTime - Long time, eg. 8:16:55
  • vbShortTime - Short time, eg. 08:16


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Vaejor   (120 posts)  Bio
Date Reply #1 on Fri 18 Apr 2003 04:15 AM (UTC)
Message
Heh, and I was just thinking about adding times to the output this morning. I figured there was a way to do it, but didn't realize it could run that cleanly.

Thanks for the code snippet. :)
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


12,680 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.