Thread Tools Display Modes
08/06/14, 07:05 PM   #1
SnowmanDK
 
SnowmanDK's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 161
Any way to get to intercept system messages?

I would like to know if I can intercept the system messages?

The reason is that I made the addon ChatStamp, which adds a timestamp to chat messages, like this:
[12:15] [@Someone] This is a chat message.
This only works for normal chat messages though. Friends logging on is still shown without that timestamp.
Is it possible to grab it so I can add a timestamp to those too?
  Reply With Quote
08/06/14, 07:18 PM   #2
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
Originally Posted by SnowmanDK View Post
I would like to know if I can intercept the system messages?

The reason is that I made the addon ChatStamp, which adds a timestamp to chat messages, like this:
[12:15] [@Someone] This is a chat message.
This only works for normal chat messages though. Friends logging on is still shown without that timestamp.
Is it possible to grab it so I can add a timestamp to those too?
Lua Code:
  1. local handlers = ZO_ChatSystem_GetEventHandlers()
  2. local originalHandler = handlers[EVENT_FRIEND_PLAYER_STATUS_CHANGED]
  3. handlers[EVENT_FRIEND_PLAYER_STATUS_CHANGED] = function(...)
  4.    return GetTimeString() .. " " .. originalHandler(...)
  5. end

A slightly different code that does the same:
Lua Code:
  1. local originalHandler = ZO_ChatSystem_GetEventHandlers()[EVENT_FRIEND_PLAYER_STATUS_CHANGED]
  2. ZO_ChatSystem_AddEventHandler(EVENT_FRIEND_PLAYER_STATUS_CHANGED, function(...)
  3.     return GetTimeString() .. " " .. originalHandler(...)
  4. end)

And do not forget that there are also other events that displays chat messages. For example EVENT_SERVER_SHUTDOWN_INFO or EVENT_GROUP_MEMBER_JOINED.
If you want to have timestamp for everything, you will have to hook or redefine all chat event handlers:

Lua Code:
  1. local handlers = ZO_ChatSystem_GetEventHandlers()
  2.  
  3. for event, handler in pairs(handlers) do
  4.    --you probably have EVENT_CHAT_MESSAGE_CHANNEL already covered, so skip this one
  5.    if event ~= EVENT_CHAT_MESSAGE_CHANNEL then
  6.       local originalHandler = handler
  7.       handlers[event] = function(...) return GetTimeString() .. " " .. originalHandler(...) end
  8.    end
  9. end

How to add timestamp to debug messages:
Lua Code:
  1. local AddMessage = CHAT_SYSTEM.AddMessage
  2. function CHAT_SYSTEM:AddMessage(text)
  3.    AddMessage(self, GetTimeString() .. " " .. text)
  4. end

Last edited by Garkin : 08/06/14 at 08:52 PM. Reason: Added example with function ZO_ChatSystem_AddEventHandler(...)
  Reply With Quote
08/06/14, 07:29 PM   #3
katkat42
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 155
Originally Posted by Garkin View Post
Lua Code:
  1. local handlers = ZO_ChatSystem_GetEventHandlers()
  2. local originalHandler = handlers[EVENT_FRIEND_PLAYER_STATUS_CHANGED]
  3. handlers[EVENT_FRIEND_PLAYER_STATUS_CHANGED] = function(...)
  4.    return GetTimeString() .. originalHandler(...)
  5. end
Does that still work? None of the social and guild-social events were in the ESOUIDocumentationP3.txt file that was released (and I had changed the events wiki page to reflect the documentation).
  Reply With Quote
08/06/14, 07:40 PM   #4
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
Originally Posted by katkat42 View Post
Does that still work? None of the social and guild-social events were in the ESOUIDocumentationP3.txt file that was released (and I had changed the events wiki page to reflect the documentation).
Yes, it works. Do you want me post code from EsoUI\Ingame\ChatSystem\ChatHandlers.lua where is defined formating function for this event?
  Reply With Quote
08/06/14, 08:34 PM   #5
katkat42
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 155
Originally Posted by Garkin View Post
Yes, it works. Do you want me post code from EsoUI\Ingame\ChatSystem\ChatHandlers.lua where is defined formating function for this event?
Nah, I just want the ZO-released documentation to be complete. Mind you, this was a big improvement over the last patch, so I'm not going to kvetch.
  Reply With Quote
08/06/14, 10:07 PM   #6
SnowmanDK
 
SnowmanDK's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 161
Thanks for the fast replies
I consider this matter solved
  Reply With Quote
08/07/14, 03:36 PM   #7
SnowmanDK
 
SnowmanDK's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 161
Hm...
I wanted to check out all the events I could intercept, so went to the esoui wiki.
Accoding to that then "EVENT_FRIEND_PLAYER_STATUS_CHANGED" has been removed from API 100008 along with quite a few other events.
I guess I would have to use "EVENT_CHAT_MESSAGE_CHANNEL" but can't seem to find what codes cover what type of message (channelID's).

Last edited by SnowmanDK : 08/07/14 at 03:41 PM.
  Reply With Quote
08/08/14, 04:33 AM   #8
mra4nii
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 42
Originally Posted by Garkin View Post
Yes, it works. Do you want me post code from EsoUI\Ingame\ChatSystem\ChatHandlers.lua where is defined formating function for this event?
How did you get it?
  Reply With Quote
08/08/14, 05:12 AM   #9
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
Originally Posted by SnowmanDK View Post
Hm...
I wanted to check out all the events I could intercept, so went to the esoui wiki.
Accoding to that then "EVENT_FRIEND_PLAYER_STATUS_CHANGED" has been removed from API 100008 along with quite a few other events.
I guess I would have to use "EVENT_CHAT_MESSAGE_CHANNEL" but can't seem to find what codes cover what type of message (channelID's).
"EVENT_FRIEND_PLAYER_STATUS_CHANGED" is still present ins 100008, ZOS just "forgot" to mention some envents in ther documentation.

I have this code in modified pChat and it works:
Lua Code:
  1. local originalHandler = ZO_ChatSystem_GetEventHandlers()[EVENT_FRIEND_PLAYER_STATUS_CHANGED]
  2. ZO_ChatSystem_AddEventHandler(EVENT_FRIEND_PLAYER_STATUS_CHANGED, function(...)
  3.     if pChat.opts.showTimestamp then
  4.         return pChat.createTimestamp(pChat.opts.colours.timestamp, GetTimeString()) .. "|r" .. originalHandler(...)
  5.     else
  6.         return originalHandler(...)
  7.     end
  8. end)

Check this topic:
PTS 1.3.0 API changes (100007 to 100008 diff)
As you can see, no events were removed, just those were added:
EVENT_GAMEPAD_PREFERRED_MODE_CHANGED
EVENT_GUILD_BANKED_MONEY_UPDATE
EVENT_GUILD_KIOSK_CONSIDER_BID_START
EVENT_GUILD_KIOSK_CONSIDER_BID_STOP
EVENT_GUILD_KIOSK_CONSIDER_PURCHASE_START
EVENT_GUILD_KIOSK_CONSIDER_PURCHASE_STOP
EVENT_GUILD_KIOSK_ERROR
EVENT_GUILD_TRADER_HIRED_UPDATED
EVENT_HERALDRY_FUNDS_UPDATED
EVENT_LUA_LOW_MEMORY
EVENT_VIBRATION


You can use Zgoo to check which events are present in game:

Last edited by Garkin : 08/08/14 at 06:04 AM.
  Reply With Quote

ESOUI » AddOns » AddOn Help/Support » Any way to get to intercept system messages?


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off