ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   Lua/XML Help (https://www.esoui.com/forums/forumdisplay.php?f=175)
-   -   Receiving chat channel (https://www.esoui.com/forums/showthread.php?t=682)

dev909 04/07/14 09:14 PM

Receiving chat channel
 
Hey all, I've been going through the wiki and can't really understand how to tell what chat channel is incoming. For example if my friend whispered me, how am I able to acknowledge the message that he sent? Also how would I be able to return a message? I'm pretty tired at the moment, and most likely missed it, but if anyone can help that would be awesome!

Tajin 04/08/14 03:04 AM

here, these two snippets should answer your question:

Lua Code:
  1. EVENT_MANAGER:RegisterForEvent("younameit", EVENT_CHAT_MESSAGE_CHANNEL, ParseChat)

Lua Code:
  1. local function ParseChat(id, channel, fromName, text)

dev909 04/08/14 06:51 AM

Alright thanks! So I'm assuming that id is the unique chat identifier, channel is the incoming channel, fromName is the person who is communicating with you, and then text is the actual text? This would solve for incoming messages but how would you return a message? Would you literally just in ParseChat return a message?

Tajin 04/08/14 07:36 AM

"parseChat" is just a function I'm using that takes the callback from the "EVENT_CHAT_MESSAGE_CHANNEL" event.

You can't send chatmessages via script.

There is a command for it...
Lua Code:
  1. SendChatMessage private (string message, integer channelId, string target)
...but its "private", so we can't use it.

dev909 04/08/14 07:55 AM

Ah...I suppose they won't give us access to it either would they..

Tajin 04/08/14 08:52 AM

I doubt it, theres already enough spamming going on without it. :(

dev909 04/08/14 09:44 AM

Damn spammers :/. Ok well another question, at the moment I'm set up so that when a whisper comes to you it lists the username in the chat log (don't criticize, I'm tweaking stuff) however after the names a "^n" is appended to the string. I tried to use string.gsub to remove them but it doesn't work. Any thoughts?

Code:

   
function incMessage(id, channel, fromName, msg)
    local name = string.gsub(fromName,"^n", "")
    notifyArray[count] = name


Tajin 04/09/14 01:29 AM

I've seen different suffixes, not just ^n so I use this:
Lua Code:
  1. local function ParseChat(id, channel, fromName, text)
  2.     i = string.find(fromName,"^",0,true)
  3.     if i ~= nil then
  4.         fromName = string.sub(fromName,0,i-1)
  5.     end
  6. ...


All times are GMT -6. The time now is 05:11 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI