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

[new feature] set bot's nickname in the group #201

Closed
lijiarui opened this issue Jan 11, 2017 · 19 comments
Closed

[new feature] set bot's nickname in the group #201

lijiarui opened this issue Jan 11, 2017 · 19 comments

Comments

@lijiarui
Copy link
Member

I'm trying to get room unique id for the bot.

Issue #90 has talked about the result of room id, @zixia says it is impossible to get the permanent id for a room when using the webwxApp API.

So, maybe we can set a unique nickname(wechaty called it display name) for a bot in the room, then we can use the bot's nickname in the room as this room's unique id.

I found wechaty can set contact's remark, but it cannot remark one's name in the room.

So could you please add an API to set one's name in the room?

@huan
Copy link
Member

huan commented Jan 11, 2017

There will be many scenarios that we need to identify a room between wechat sessions. Your idea is an excellent solution that makes Wechaty can identify room between sessions.

Could you please make an API proposal for this new feature in this issue? We can discuss based on it.

@huan huan changed the title 【new feature】set bot's nickname in the group [new feature] set bot's nickname in the group Jan 11, 2017
@lijiarui
Copy link
Member Author

lijiarui commented Jan 11, 2017

Thanks! here is my proposal.

  1. Add the following obj from Room Class in Contact property
export type RoomRawMember = {
  UserName:     string
  NickName:     string
  DisplayName:  string
}
  1. maybe the following API is a good choice:
    Contact.displayname() : get one's nickname in the group
    Bot.displayname(name: string) : set the bot's nickname in the group, because we cannont set other's nickname in the group
    Bot.displayname(null): delete the bot's nickname in the group

@huan
Copy link
Member

huan commented Jan 11, 2017

This proposal is not complete because the design leaks important information.

Contact.displayname() : get one's nickname in the group

  1. how could this API get displayname, which room?

Bot.displayname(name: string) : set the bot's nickname in the group, because we can not set other's nickname in the group

  1. same as Q1: which room?

I think your displayname should rename to displayName, and this method should belong to a Room instance?

Also, how could we get Display Name from another Contact in a particular room? This scenario should be considered in the design as well.

@huan
Copy link
Member

huan commented Jan 11, 2017

And I forgot the most important part: does Web Wechat support change display name in a room ?

@lijiarui
Copy link
Member Author

I'm sorry I forgot the most important part.....
so, any others have any good idea, welcome......

@huan
Copy link
Member

huan commented Jan 11, 2017

@lijiarui What's your mean "forgot the most important part"?

Did you mean you confirmed that Web Wechat does not support modify display name?

@dcsan
Copy link

dcsan commented Jan 11, 2017

I can confirm that you can use the "edit alias" feature on a user name.

It does NOT seem to work on your own username by clicking personal profile icon

BUT if you select yourself in a group and then change it this will seem to work.

My phone also updates, so the information on updated alias is being sent to the network / propagated.
BUT i don't see any messages in wechaty log when editing aliases. So perhaps alias update events are not sent to wechaty/web client, or you have some other filtering of the messages higher in the chain that stops them being logged.

@lijiarui
Copy link
Member Author

@zixia yes, I found Web Wechat does not support modify display name in the group....

@dcsan Do you have some good idea to help?

@huan
Copy link
Member

huan commented Jan 12, 2017

@dcsan Awesome, your method is the key to implementing this feature, thanks, buddy!

@lijiarui Could you follow @dcsan's method, and continue editing your API proposal with my suggestion?

@huan
Copy link
Member

huan commented Jan 12, 2017

@lijiarui could you please confirm with @dcsan whether "select yourself in a group and then change alias" works in web wechat?

I just tried this method, it seems not work as expected because I can not see any change of my room display name on my phone.

@lijiarui
Copy link
Member Author

For me , "select yourself in a group and then change alias" doesn't works in web wechat.

When I change bot's remark in the room, it doesn't have any change in my phone.

And, I found when using webWeixin, I thought I changed one's display name in a room, but actually I changed one's remark. So, when I change one's display name in a room, it works in all the room....

@dcsan
Copy link

dcsan commented Jan 13, 2017

I think remark and alias are mixed up in the english translation of wechat webUI.

Also when I checked just now, the phone did NOT update. I'm sure it did before... >.<

I also enabled more debugging and don't see any messages when changing that field, so I think this maybe a client side only setting, or at least only shared with wechat servers and not echoed to other clients.

@lijiarui
Copy link
Member Author

remark === alias as we talked in wechat developers home

@huan
Copy link
Member

huan commented Jan 13, 2017

  1. About the name remark

All methods and variables in webwxapp that modify alias are named remark. That is the reason why Wechaty use remark instead of alias

  1. Get Display Name for a contact in a room

In webwxapp, the user alias name in a room is named DisplayName.

Even we can not set Display Name, we can still get the display name without any problem because this name is saved in the Room's MemberList array variable.

To identify the room as @dcsan said before, we can set the display name on our phone, then get display name from Wechaty. Bingo, it worked.

So @lijiarui it's still worth to go ahead for designing the API because of it will be useful even we can only read it.

@lijiarui
Copy link
Member Author

lijiarui commented Jan 18, 2017

Oh, I'm sorry, should be #173

@huan
Copy link
Member

huan commented Feb 10, 2017

@lijiarui Is this issue outdated and should be close now?

@lijiarui
Copy link
Member Author

lijiarui commented Mar 12, 2017

We cannot set bot's alias in a room, but we can get the bot's alias in the room.
So if we want to get the room unique id, we can set the bot's alias manually, then use room.alias(contact) to check the alias.

Learn more: FAQ

@dcsan
Copy link

dcsan commented Mar 13, 2017

neat hack. So basically you manually name your own bot something related to the roomname.

@lijiarui
Copy link
Member Author

yes,maybe is the best way so far. If you have any good idea, glad to hear from you ^-^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants