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

Feature Request: Message Could Mention All Members in Room but Not Announcement. #2394

Open
4 tasks
su-chang opened this issue Mar 30, 2022 · 38 comments
Open
4 tasks
Assignees
Labels
feature request stale Issue has not had recent activity or appears to be solved. Stale issues will be automatically closed

Comments

@su-chang
Copy link
Member

Background

When we want to send message which could mention all members in the room, we could set room announcement for it.

But it will stay on the board until the next new announcement coming. If this message is not so much important to set on the board, we really need some other method to suit this case.

For example, mention all members only. Just like:

@all hello, everybody here.

And this feature has been supported in WeCom now.

Feature Request

Design One

Above all, I'd like to make it into method room.say() and could transfer a special params like: [ @all ].

Interface

async say (sayable: Sayable | TemplateStringsArray, ...varList: unknown[]): Promise<void | MessageInterface>

Example

const room = wechaty.Room.find({ name: 'Mention all members room' })
await room.say('hello, everybody here.', ...[ '@all' ])

This design in common sense. But will process with the special params [ '@all' ], and with a little trouble for some puppets adaption.

Design Two

Another way to support it.

Interface

async announce (text: string, pin: boolean = true) : Promise<void>

Maybe the params pin could be replaced by a better name.

Example

const room = wechaty.Room.find({ name: 'Mention all members room' })
await room.announce('hello, everybody here.', false) // would regard it as text message with mention only

This design could make use and implement it easily. If you don't want to set an announcement, just transfer a false params. It will be a text message which could only mention all members in room.

Todo List

  • PR in wechaty
  • PR in puppet
  • PR in puppet-service
  • PR in grpc
@windmemory
Copy link
Member

I would like to vote design one, seems like that one is more common across different IMs.

@huan
Copy link
Member

huan commented Mar 30, 2022

I feel design two is more clear to me, and at the same time there will also be no problem across other IMs? (please correct me if I'm wrong @windmemory )

@su-chang Please feel free to go ahead to create a PR to demonstrate your design two, let's continue discussing based on the PR, and thank you very much for your new feature RFC!

@windmemory
Copy link
Member

I think the main problem for design two is that, the @ALL symbol could show up in any position inside a message, not only at the beginning, but also somewhere in the middle. So if we do design two, the method will lack of the ability to explicitly set the position of @ALL.

@huan
Copy link
Member

huan commented Mar 30, 2022

Could we just put a string @all in the content?

Like:

room.announce('Attention! @all Please read: ...', false)

Does that fulfill your requirement?

@windmemory
Copy link
Member

I think this might cause unintended bugs to Wechaty. What if the user call this function like this:

room.announce('Attention! @all Please read: ...', true)

Currently it is not possible to create such announcement with @ALL in the middle of the message, but this is allowed by the method. And actually @ALL message is just a message, not an announcement, we should keep that two concepts clearly separated.

@huan
Copy link
Member

huan commented Mar 31, 2022

I don't think it will be an issue because the Wechaty will not care about the @ in the message string.

Users can put whatever they want into that string, and wechaty will just pass it as a string.

Is there anything I have missed?

@windmemory
Copy link
Member

This is passing a wrong message to the developer, which is saying: announcement would support @ALL in the middle of the message, but actually it is not.
When we design the API, we should also consider about whether the API is properly aligned with the real functionality.

Besides the reason above, the most important reason is:

announcement@all message

This is a common design across different IMs, like Lark we are using the most during our work, setting an announcement does not require to publish this to the room, but when you want to announce an announcement, you can manually publish it.
image
And after you publish the announcement, it is not a regular message, but a announcement message, like this:
image
And here is the @all message looks like:
image

So I think if we merge the two concepts, annoucement and @all message together, it will introduce a lot of troubles in the future, this is why I don't like the design two, but prefer to implement design one.

@huan
Copy link
Member

huan commented Mar 31, 2022

I think I got your idea.

So let's just ignore the @all for now, and focus on the improvements of the announce() methods.

Does this look good to you?

@windmemory
Copy link
Member

I think we are discussing about how to implement @all feature here, so I don't think we could ignore the @all for now.

Shall we continue discuss the @all feature here?

@hcfw007
Copy link
Member

hcfw007 commented Apr 15, 2022

I like design one because it mentioning all is sending a message, not setting a room announcement. So to use room.say is much better than room. announce.

@hcfw007 hcfw007 mentioned this issue Apr 18, 2022
4 tasks
@hcfw007
Copy link
Member

hcfw007 commented Apr 18, 2022

@huan please check out my draft PR at your convenience. I think this design requires no change in wechaty-puppet and wechaty-grpc (as we pass mention id list as string[], and '@ALL' can be regarded as a special id).

@huan
Copy link
Member

huan commented Apr 18, 2022

Thanks for the PR. I'll think about the magic string '@ALL' for some time.

Basically, I do not like magic strings. (An alternate would use a Symbol, but it should be not used at the user end because it's not serializable)

@hcfw007
Copy link
Member

hcfw007 commented Apr 18, 2022

I don't like it either. Perhaps we can create a special Contact Instance representing 'all contacts'? Or define a static string in wechaty-puppet?

@hcfw007
Copy link
Member

hcfw007 commented Apr 26, 2022

@huan Have you thought it through? We may also add a method like room.SayToAll('something'), however if we want to make the '@ALL' string in the middle of the text (via templateStringArray), we still need to use room.say. As we pass contact ids to puppet implementation, if we don't want to change current puppet.sendMessageText design, using this magic string seems inevitable.

@huan
Copy link
Member

huan commented Apr 26, 2022

Perhaps we can create a special Contact Instance representing 'all contacts'? Or define a static string in wechaty-puppet?

Neither the special contact nor static string in puppet make me feel comfortable.

add a method like room.SayToAll('something')

Adding a method for this tiny feature looks like a overkill

async announce (text: string, pin: boolean = true)

How do you think about the design 2? @su-chang raise the propose and I feel it is acceptable for me.

@hcfw007
Copy link
Member

hcfw007 commented Apr 26, 2022

I don't know...After all we are sending a text message in a room, use announce doesn't make much sense...

@hcfw007
Copy link
Member

hcfw007 commented Apr 26, 2022

However it does make this problem much easier. We don't even have to handle any other '@' in the string. (e.g. '@ALL @Someone Something just happened!'.). We can pass the string as it is.
If you like design 2 better, I can open a PR for that.

@huan
Copy link
Member

huan commented Apr 26, 2022

We don't even have to handle any other '@' in the string. (e.g. '@ALL @Someone Something just happened!'.). We can pass the string as it is.

That's the point!

Please feel free to open an PR and let's continue discussing based on it.

@hcfw007
Copy link
Member

hcfw007 commented Apr 27, 2022

Hold on a moment before I start this PR cause I just found that you can @Someone more than once in both Lark and Whatsapp. (and that effects the content, not just the notification).
So we cannot just call using room. announce( '@Someone Something just happened!', false). Further more, you can @ the same target more than once.
e.g.:

  1. Lark:
    image
  2. Whatsapp:
    image

Any idea about implementing that in room. announce? We can do that in room.say() because '@ALL' is just a regular member in mention list.

@hcfw007
Copy link
Member

hcfw007 commented Apr 28, 2022

@huan ping

@huan
Copy link
Member

huan commented Apr 28, 2022

I can not understand what's the point of mentioning one user name twice in one message?

And could you explain why "@ALL is just a regular member in mention list"? What do you mean a "regular"?

@hcfw007
Copy link
Member

hcfw007 commented Apr 28, 2022

I can not understand what's the point of mentioning one user name twice in one message?

e.g. there is a new member in the company, and we want to give the new comer a warm welcome:
'@ALL Attention everyone, @Someone has just joined us, please show your passion and give him a warm welcome'
There can be more scenarios, but I believe what really matters is: IM support this kind of usage, and we should not the stop the user from using that.

And could you explain why "https://github.com/ALL is just a regular member in mention list"? What do you mean a "regular"?

I mean in this mentionList Array, '@ALL' is just like any other member (Contact instances), it can show up in any position of the text, there can be more than one '@ALL', etc.

@huan
Copy link
Member

huan commented Apr 28, 2022

Could you please convert this requirement into a end user source code to express it?

I think the current API design will not stop you doing them.

@hcfw007
Copy link
Member

hcfw007 commented May 7, 2022

Take this as example:
image

  1. with magic-string approach:
const room = bot.room.find({ name: 'dev' })
const contact = bot.contact.find({ name: '王楠' })
room.say`${@all}${contact}刚刚修复了一个bug` // i'm not sure if I have used templateStringArray correctly
  1. with announce approach:
const room = bot.room.find({ name: 'dev' })
const contact = bot.contact.find({ name: '王楠' })
room. announce('@王楠刚刚修复了一个bug', false)

The thing is, the '@王楠' in the second approach will not be a real mention. You can not click to get the contact nor the text will be blue in Lark.

@huan
Copy link
Member

huan commented May 8, 2022

room.say(['', ',', '刚刚修复了一个bug'], '@ALL', contact) // i'm not sure if I have used templateStringArray correctly

No, the above usage of the TemplateString is definitely NOT correct.

The correct usage is:

room.say`@all ${contact} 刚刚修复了一个bug`

I have discussed the Tagged Template topic with @wechaty/juzi before about the TemplateArrayString before, see:

@hcfw007
Copy link
Member

hcfw007 commented May 9, 2022

@huan I have updated my example.
The main point is: although it's a rare occasion, it's supported by multiple IMs, and we should not block user from using it.
(by it I mean mention someone while also mentioning everyone)

@huan
Copy link
Member

huan commented May 9, 2022

The magic string proposal is not a good idea so let's not use it as possible as we can.

According to your example code, I think the below code is what you need:

room. announce`@所有人 ${contact} 刚刚修复了一个bug`

BTW: I think this is a Lark-related rich feature? Is the Wechaty Puppet Lark able to be used in production now?

@hcfw007
Copy link
Member

hcfw007 commented May 9, 2022

The magic string proposal is not a good idea so let's not use it as possible as we can.

According to your example code, I think the below code is what you need:

room. announce`@所有人 ${contact} 刚刚修复了一个bug`

BTW: I think this is a Lark-related rich feature? Is the Wechaty Puppet Lark able to be used in production now?

This will require room.announce to accept templateStringArray also. This does solve the problem so I'm happy with it.

For Puppet-Lark, I don't think so. But whatsapp have similar feature, you can mention the same person more than once in the one message.

@huan
Copy link
Member

huan commented May 9, 2022

This will require room.announce to accept templateStringArray also. This does solve the problem so I'm happy with it.

Glad to know.

Then the next question will be how can we pass another argument to the TemplateStringArray method.

@hcfw007
Copy link
Member

hcfw007 commented May 10, 2022

Then the next question will be how can we pass another argument to the TemplateStringArray method.

Also how should we pass this to the puppet. puppet.sendMessageText() accepts ContactId[], and if we pass '@ALL' we are kinda using magic string again.

@huan
Copy link
Member

huan commented May 10, 2022

Also how should we pass this to the puppet. puppet.sendMessageText() accepts ContactId[],

I think we should use puppet.roomAnnounce() instead of the sendMessageText()?

if we pass '@ALL' we are kinda using magic string again.

I think this is just a string instead of a magic string.

@hcfw007
Copy link
Member

hcfw007 commented May 10, 2022

Maybe we can treat all TemplateStringArray room announces as a mention all message.
Because any mention will be degraded to regular text in IMs I use, there is no point to @Someone when setting announcements.

@huan
Copy link
Member

huan commented May 10, 2022

Maybe we can treat all TemplateStringArray room announces as a mention all message.

Brilliant!

I agree with you and feel this is a perfect solution.

@hcfw007 hcfw007 mentioned this issue May 17, 2022
@hcfw007
Copy link
Member

hcfw007 commented May 17, 2022

@huan can you check out this draft #2418?
It's a bit wierd since if we want to mention all while mentioning other people, we have to pass one more parameter: mentionList.

@hcfw007
Copy link
Member

hcfw007 commented May 5, 2023

After discussion in Wechaty Community Meeting (brief here)
We have dicided to achieve @ALL message by mentioning the room.
TODO:

  1. In wechaty, we should allow passing RoomInterface into mention list and say with template string array.
  2. Split string into string array in wechaty-grpc to match @ with position in text.
  3. Create a new messageSendText method to send mention message with contact Id instead of @+name.

Copy link

dosubot bot commented Nov 20, 2023

Hi, @su-chang. I'm Dosu, and I'm helping the wechaty team manage their backlog. I wanted to let you know that we are marking this issue as stale.

From what I understand, this issue is a feature request to add the ability to mention all members in a room without setting an announcement. There have been two design options proposed: one is to add a special parameter to the room.say() method, and the other is to introduce a new room.announce() method with a boolean parameter to indicate whether to set an announcement. There has been a discussion between users windmemory and huan about the design options, with windmemory preferring design one and huan preferring design two. User hcfw007 has opened a draft PR for design two and huan has requested to check it out. After further discussion, it has been decided to achieve the @ALL message by mentioning the room, and a todo list has been provided for implementing this solution.

Before we proceed, we would like to confirm if this issue is still relevant to the latest version of the wechaty repository. If it is, please let us know by commenting on the issue. Otherwise, feel free to close the issue yourself or it will be automatically closed in 7 days.

Thank you for your understanding and contribution to the wechaty community.

@dosubot dosubot bot added the stale Issue has not had recent activity or appears to be solved. Stale issues will be automatically closed label Nov 20, 2023
@huan huan self-assigned this Nov 22, 2023
@huan
Copy link
Member

huan commented Nov 22, 2023

@dosubot I'll take care about it, please keep it open.

@dosubot dosubot bot removed the stale Issue has not had recent activity or appears to be solved. Stale issues will be automatically closed label Nov 22, 2023
Copy link

dosubot bot commented Nov 22, 2023

@huan Could you please help @su-chang with this issue? They have indicated that it is still relevant and needs assistance. Thank you!

@dosubot dosubot bot added the stale Issue has not had recent activity or appears to be solved. Stale issues will be automatically closed label Feb 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request stale Issue has not had recent activity or appears to be solved. Stale issues will be automatically closed
Projects
None yet
Development

No branches or pull requests

4 participants