Skip to content
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

Merged
merged 7 commits into from
Aug 13, 2024

Conversation

maxim-productengine
Copy link
Contributor

No description provided.

@bennettgoble
Copy link
Member

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!

Copy link
Collaborator

@nat-goodspeed nat-goodspeed left a 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);
Copy link
Collaborator

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.

Copy link
Contributor Author

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;
Copy link
Collaborator

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);
}
Copy link
Collaborator

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.

Copy link
Contributor Author

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.

#include "llgroupactions.h"
#include "llimview.h"

static const F32 GROUP_CHAT_THROTTLE_PERIOD = 1.f;
Copy link
Collaborator

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
Copy link
Collaborator

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.

Copy link
Contributor Author

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'
Copy link
Collaborator

@nat-goodspeed nat-goodspeed Aug 12, 2024

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.

Copy link
Contributor Author

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.
@maxim-productengine maxim-productengine merged commit 0832129 into release/luau-scripting Aug 13, 2024
12 checks passed
@maxim-productengine maxim-productengine deleted the lua-groupchat branch August 13, 2024 12:48
@github-actions github-actions bot locked and limited conversation to collaborators Aug 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants