-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lua api for sending group messages #2240
Conversation
Hey, @maxim-productengine. Thanks for the PR --could you include an example of how this is used in your PR description? This would help reviewers quickly understand what the new API looks like! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. See also the Throttle proposal in #2265.
private: | ||
void startGroupChat(LLSD const &data); | ||
void leaveGroupChat(LLSD const &data); | ||
void sendGroupIM(LLSD const &data); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way to discover and join an existing group chat, or is that an automatic response to an invitation?
Can a Lua script monitor the content of a particular group chat? The LLEventAPI
documentation string mentions "intercept," though it seems the original author (ahem) neglected to follow up on that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can skip startGroupChat
step, if group chat has been already opened manually.
We don't have 'group chat listener' for now. So, if/when we add one, it's probably a good idea to provide a list of current opened group conversations.
p.message = "[From " + avatar_name.getDisplayName() + "]\n" + p.message; | ||
auto [message, is_lua] = LLStringUtil::withoutPrefix(p.message, LUA_PREFIX); | ||
std::string prefix = is_lua ? "LUA - " : ""; | ||
p.message = "[From " + prefix + avatar_name.getDisplayName() + "]\n" + message; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay: the fact that a message originated from Lua arrives as a message prefix, and this code moves it from the message field to the [From]
field. I see. It took me a moment; maybe a comment?
if (LLFloaterIMSession *conversationFloater = LLFloaterIMSession::findInstance(session_id)) | ||
{ | ||
LLFloater::onClickClose(conversationFloater); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is that what leaveSession()
did? I'm curious about the reason for this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without this change you could leave group chat session, but that group conversation was still opened in Chat/Conversations floater, which was wrong. Closing appropriate conversation floater will do both.
indra/newview/groupchatlistener.cpp
Outdated
#include "llgroupactions.h" | ||
#include "llimview.h" | ||
|
||
static const F32 GROUP_CHAT_THROTTLE_PERIOD = 1.f; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it important that this be F32
, since the time tracking uses F64
?
-- 0 is public nearby channel, other channels are used to communicate with LSL scripts | ||
function LLChat.sendChannel(msg, channel) | ||
leap.send('LLChatBar', {op='sendChat', channel=channel, message=msg}) | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I'm concerned, you could just add a channel
parameter to sendNearby()
and add channel=channel
to the event table at line 10. If the caller passes only the msg
parameter, channel
will be nil
, and setting a Lua table key to nil
deletes it from the table -- making it exactly like the present sendNearby()
event table.
I like the comment, though. Definitely keep that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, it makes sense.
LLAgent = require 'LLAgent' | ||
popup = require 'popup' | ||
|
||
local OK = 'OK_okcancelbuttons' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we provide aliases in the popup
module? To be honest, I'm not sure why the notification response strings are so awkward.
Or the popup
module could examine the existing key=true
result and add a result=shorthand
key.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, I was thinking about it too. It would be better to provide handy built-in check, instead of using this 'magic' OK_okcancelbuttons
.
Add Throttle and LogThrottle classes to manage throttled APIs.
No description provided.