Quantcast
Download
(5 Kb)
Download
Updated: 08/02/16 07:08 AM
Compatibility:
Shadows of the Hist (2.5)
Updated:08/02/16 07:08 AM
Created:09/09/14 09:21 AM
Monthly downloads:24
Total downloads:895
Favorites:2
MD5:
libChat2
Version: 9
by: Ayantir [More]
libChat2 is a rewrited copy of original libChat.

Please note that libChat2 is not an addon, it's a library, it must be used as a dependancy



Why this library :

libChat2 is intended to rewrite messages, sender name or some standardized system messages sent to the chat. If you need to rewrite one of those strings, it's the library you need !

Please note that libChat2 does not YET modify messages sen trought d() or CHAT_SYSTEM:AddMessage(), see you soon !



Integration :
In your Manifest file (ex addon.txt), please include :
Code:
path/libChat2/libChat2.lua


Then in your addon, you will need to registrer library :
Lua Code:
  1. -- Registering librairies
  2. local LC = LibStub('libChat-1.0')


And register methods you want to use (register only the one you need !) :
Lua Code:
  1. -- libChat
  2.  
  3.     -- All those events outputs to the ChatSystem
  4.    
  5.     -- First APPEND something to a message sent by EVENT_CHAT_MESSAGE_CHANNEL
  6.     LC:registerAppendDDSBeforeAll(myFuncToAppendDDSBeforeAll, addonName)
  7.     LC:registerAppendTextBeforeAll(myFuncToAppendTextBeforeAll, addonName)
  8.     LC:registerAppendDDSBeforeSender(myFuncToAppendDDSTextureBeforeSenderName, addonName)
  9.     LC:registerAppendTextBeforeSender(myFuncToAppendTextBeforeSenderName, addonName)
  10.     LC:registerAppendTextAfterSender(myFuncToAppendTextAfterSenderName, addonName)
  11.     LC:registerAppendDDSAfterSender(myFuncToAppendDDSAfterSenderName, addonName)
  12.     LC:registerAppendDDSBeforeText(myFuncToAppendDDSBeforeText, addonName)
  13.     LC:registerAppendTextBeforeText(myFuncToAppendTextBeforeText, addonName)
  14.     LC:registerAppendTextAfterText(myFuncToAppendTextAfterText, addonName)
  15.     LC:registerAppendDDSAfterText(myFuncToAppendDDSAfterText, addonName)
  16.    
  17.     -- Then CHANGE something in the message
  18.     -- registerName = from for EVENT_CHAT_MESSAGE_CHANNEL, registerText = message for EVENT_CHAT_MESSAGE_CHANNEL, registerFormat = Whole "message" (from + name + colors + infoarray, etc) for EVENT_CHAT_MESSAGE_CHANNEL
  19.     LC:registerName(myFuncToChangeFromName, addonName)
  20.     LC:registerText(myFuncToChangeText, addonName)
  21.     LC:registerFormat(myFuncToChangeTheEntireWholeMessage, addonName)
  22.    
  23.     -- Because it is output to the chat, this sysmessage can also be modified
  24.     -- registerFriendStatus = message for EVENT_FRIEND_PLAYER_STATUS_CHANGED
  25.     LC:registerFriendStatus(myFuncToChangeFriendStatusMessage, addonName)
  26.    
  27.     -- Those ESOUI events can also be modified
  28.     -- registerIgnoreAdd = message for EVENT_IGNORE_ADDED, registerIgnoreRemove = message for EVENT_IGNORE_REMOVED
  29.     -- registerGroupTypeChanged = message for EVENT_GROUP_TYPE_CHANGED
  30.     LC:registerIgnoreAdd(myFuncToChangeIgnoreAddMessage, addonName)
  31.     LC:registerIgnoreRemove(myFuncToChangeIgnoreRemoveMessage, addonName)
  32.     LC:registerGroupTypeChanged(myFuncToChangeGroupTypeChangedMessage, addonName)


About registerFormat :

Please note that :registerFormat overwrite all libChat addons. If you need to use registerFormat, please note that your addon may broke some others, so be careful !
If you want to use this method and keep rewrited text by others addons, original and rewrited strings are available when playing with registerFormat



Functions and arguments available :

Each method come with arguments for your function :
Please note that for all methods, addonName is optionnal and used to register addon with libChat for debugging.

LC:registerName(myFuncToChangeFromName [, addonName ])
  • channelID : integer, is the CHAT_CHANNEL of the message
  • from : string, is the sender name of the message (can be Charactername or DisplayName)
  • isCustomerService : boolean, true is the message come from a CustomerService Member



LC:registerText(myFuncToChangeText [, addonName ])
  • channelID : integer, is the CHAT_CHANNEL of the message
  • from : string, is the sender name of the message (can be Charactername or DisplayName)
  • text : string, message sent to the client
  • isCustomerService : boolean, true is the message come from a CustomerService Member



LC:registerFormat(myFuncToChangeMessage [, addonName ])
  • channelID : integer, is the CHAT_CHANNEL of the message
  • from : string, is the sender name of the message (can be Charactername or DisplayName) *This text can be rewrited by another addon
  • text : string, message sent to the client *This text can be rewrited by another addon
  • isCustomerService : boolean, true is the message come from a CustomerService Member
  • originalFrom : string, is the sender name of the message (can be Charactername or DisplayName) *This text can be rewrited by another addon which do not use libChat
  • originalText : string, message sent to the client *This text can be rewrited by another addon which do not use libChat
  • DDSBeforeMessage : string, DDS added by another addon if applicable
  • TextBeforeMessage : string, text added by another addon if applicable
  • DDSBeforeSender : string, DDS added by another addon if applicable
  • TextBeforeSender : string, text added by another addon if applicable
  • DDSAfterSender : string, DDS added by another addon if applicable
  • TextAfterSender : string, text added by another addon if applicable
  • DDSBeforeText : string, DDS added by another addon if applicable
  • TextBeforeText : string, text added by another addon if applicable
  • TextAfterText : string, text added by another addon if applicable
  • DDSAfterText : string, DDS added by another addon if applicable

LC:registerAppendDDSBeforeAll(myFunc [, addonName ])
LC:registerAppendTextBeforeAll(myFunc [, addonName ])
LC:registerAppendDDSBeforeSender(myFunc [, addonName ])
LC:registerAppendTextBeforeSender(myFunc [, addonName ])
LC:registerAppendTextAfterSender(myFunc [, addonName ])
LC:registerAppendDDSAfterSender(myFunc [, addonName ])
LC:registerAppendDDSBeforeText(myFunc [, addonName ])
LC:registerAppendTextBeforeText(myFunc [, addonName ])
LC:registerAppendTextAfterText(myFunc [, addonName ])
LC:registerAppendDDSAfterText(myFunc [, addonName ])
  • channelID : integer, is the CHAT_CHANNEL of the message
  • from : string, is the sender name of the message (can be Charactername or DisplayName)
  • text : string, message sent to the client
  • isCustomerService : boolean, true is the message come from a CustomerService Member


About Appending :
For now, each method can only be registered by one addon.
If 2 addons try to load the same method, one will be skipped, but the both will appear in manager with /libchat. In next future, Append methods will accept unlimited calls

Appending format :

If a message look like this :
{OptionnalESOUIFormat}{Sender}{OptionnalESOUIFormat}{Message}{OptionnalESOUIFormat}
ex : [Group][Ayantir] : Hello World

Appends can add strings using this template :
{DDSBeforeAll}{TextBeforeAll}{OptionnalESOUIFormat}{DDSBeforeSender}{TextBeforeSender}{Sender}{TextAfterSender}{DDSAfterSender}{OptionnalESOUIFormat}{DDSBeforeText}{TextBeforeText}{Message}{TextAftertext}{DDSAftertext}{OptionnalESOUIFormat}
ex : [20h12][Group][VR14][Ayantir] : Hello World

In this exemple are used : DDSBeforeAll (smiley), TextBeforeAll ([20h12]), TextBeforeSender ([VR14]) and DDSAftertext (smiley)


LC:registerFriendStatus(myFuncToChangeFriendStatusMessage [, addonName ])
  • displayName : string, DisplayName of the Account triggering the message
  • characterName : string, characterName of the Account triggering the message
  • oldStatus : integer, is the old status of the account
  • newStatus : integer, is the new status of the account



LC:registerIgnoreAdd(myFuncToChangeIgnoreAddMessage [, addonName ])
  • displayName : string, DisplayName of the Account ignored



LC:registerIgnoreRemove(myFuncToChangeIgnoreRemoveMessage [, addonName ])
  • displayName : string, DisplayName of the Account ignored



LC:registerGroupTypeChanged(myFuncToChangeGroupTypeChangedMessage [, addonName ])
  • largeGroup : boolean, true is newStatus is a large group



Then simply write your function with the parameters you want to use :

ex :

Lua Code:
  1. local LC = LibStub('libChat-1.0')
  2.  
  3. LC:registerAppendTextBeforeAll(AppendTime, Addon.Name)
  4.  
  5. -- Will append Time for party messages only before all text
  6. local function AppendTime(channelID, from, text, isCustomerService)
  7.  
  8.     if channelID == CHAT_CHANNEL_PARTY then
  9.         return GetTimeString()
  10.     else
  11.         return ""
  12.     end
  13.    
  14. end


My Add-On does nothing

If your Chat Addon does nothing, and your code is running well, it's generally because another chat addon bypass your code. libChat2 helps you to handle this problem by adding methods to add or rewrite text only where you need it, without broking other addons.
Using registerAppendDDSBeforeAll, registerAppendTextBeforeAll, registerAppendDDSBeforeSender, registerAppendTextBeforeSender
registerAppendTextAfterSender, registerAppendDDSAfterSender, registerAppendDDSBeforeText, registerAppendTextBeforeText, registerAppendTextAfterText, registerAppendDDSAfterText
helps other devs too.

Please note that this feature is only available if other addon use libchat too
If the other addon rewrite Chat without libChat, this one can bypass your code too


Debug for end-Users

libChat2 now come with an embedded debug, trought /libchat. It will dump which methods are registered with which addon and help you if your addon does "nothing"

ex :

Code:
---- libchat2 debug ----
Note : 2 addons registering same method will provoke conflicts
registerFriendStatus set with addon  #1 pChat, #2 GuildNotificator,
registerAppendTextAfterSender set with addon  #1 GuildChat,
registerGroupTypeChanged set with addon  #1 pChat,
registerAppendTextBeforeSender set with addon  #1 GuildChat,
registerFormat set with addon WARNING : method overwrite Sender name and Message ! #1 pChat,
registerIgnoreRemove set with addon  #1 pChat,
registerIgnoreAdd set with addon  #1 pChat,
---- end of libchat2 debug ----
Here you can see that addon :
- pChat registers : registerFriendStatus, registerGroupTypeChanged, registerFormat, registerIgnoreRemove, registerIgnoreAdd
- GuildNotificator registers : registerFriendStatus
- GuildChat registers : registerAppendTextBeforeSender, registerAppendTextAfterSender


Any problem or requesting a little help

- Send a Private Message or leave a comment
9
======
- 2 variables leaked fixed
- Rename of a method to match its sisters names
- Handle the modifications of EVENT_CHAT_CHANNEL

1.6
======
- Fixed the method to correctly register :registerAppendTextBeforeAll()
- Fixed few variables leaking to global

Justice
======
- Added methods to append text
- Added an integrated manager
- Doc reworked

v1.2
======
- funcXX vars were global, fixed

v1.1
======
- Added backward compatibility with original libChat
Optional Files (0)


Archived Files (5)
File Name
Version
Size
Author
Date
1.6
5kB
Ayantir
08/22/15 07:45 AM
Justice
5kB
Ayantir
02/21/15 09:03 AM
1.2
4kB
Ayantir
09/16/14 09:35 AM
1.1
4kB
Ayantir
09/11/14 04:50 PM
1
3kB
Ayantir
09/09/14 09:21 AM


Post A Reply Comment Options
Unread 08/22/15, 07:45 AM  
Ayantir
 
Ayantir's Avatar
AddOn Author - Click to view AddOns

Forum posts: 971
File comments: 1493
Uploads: 31
Re: registerAppendTextBeforeAll currently not working

Originally Posted by Pyranea
You need to add this in "libChatMessageChannelReceiver":

Code:
if funcTextBeforeAll then
    TextBeforeAll = funcTextBeforeAll(channelID, from, text, isCustomerService)
end
Oh yes, thanks fixed. I've also fixed some local leaking (thank you circonian )
__________________
Obsessive Compulsive Coder

My little french Guild: Cercle de l'Eveil
Report comment to moderator  
Reply With Quote
Unread 08/22/15, 07:15 AM  
Pyranea

Forum posts: 0
File comments: 3
Uploads: 0
registerAppendTextBeforeAll currently not working

You need to add this in "libChatMessageChannelReceiver":

Code:
if funcTextBeforeAll then
    TextBeforeAll = funcTextBeforeAll(channelID, from, text, isCustomerService)
end
Report comment to moderator  
Reply With Quote
Unread 02/21/15, 09:12 AM  
Ayantir
 
Ayantir's Avatar
AddOn Author - Click to view AddOns

Forum posts: 971
File comments: 1493
Uploads: 31
Why this $%!#? library ?!

Heya nobody here,

Please note that for the very few chat addons we get in ESO we're alsmost each other broking our addons.

So :
  • If you REWRITE or APPEND something to a message sent by EVENT_CHAT_MESSAGE_CHANNEL and don't use libchat, you will BROKE other chat addons.

Adding timestamps, smileys, info, or anything else to thoses messages ? Please use libChat.

Thank you !
__________________
Obsessive Compulsive Coder

My little french Guild: Cercle de l'Eveil
Report comment to moderator  
Reply With Quote
Post A Reply



Category Jump: