Brodgar client

hafen.event: The Chat

A channel appearing, going away or taking the tab, and a line landing in one. A channel is one character’s: the chat is a window of that login’s HUD. So each key hands the thing it is about and that character’s Session last. Part of the catalogue.

hafen.event():on("MessageAdded", function(message, session)
  if not message:mine() then
    hafen.log():write(session:character() .. " heard: " .. message:text())
  end
end)

Event Payload Fires
ChannelAdded Channel A channel appears in that character’s chat.
ChannelRemoved Channel A channel goes away. The object still keys your table, and every read on it is nil.
ChannelSelected Channel That character’s chat changed tab.
MessageAdded Message A line lands in a channel: any channel, any character.
Rule Detail
Added before selected The client puts a tab up and picks it in one motion, so a channel arriving fires both, in that order.
ChannelSelected fires on a change Whether the player clicked the tab or an addon wrote session:chat():selected(channel). Naming the tab already on screen fires nothing. Losing the selected channel selects nothing and fires nothing: the payload is a channel, and none was picked.
ChannelRemoved is already gone channel:exists() is false. channel:name(), :kind() and :urgency() read nil. The payload is the object ChannelAdded handed you (channels are interned): match on it, not on a name you can no longer read.
MessageAdded includes your own lines The client draws your line once the server sends it back. message:mine() tells them apart. message:channel() is the object ChannelAdded handed you. A line is reported after its channel was reported to arrive.

See Also