Skip to content

Contact.name()cannot identify emoji when name contain emoji #118

@lijiarui

Description

@lijiarui

Run npm run doctor or wechaty run doctor(for docker user), paste output here

> wechaty@0.6.40 doctor /Users/lijiarui/Documents/git/wechaty
> ts-node bin/doctor


#### Wechaty Doctor

1. Wechaty version: #git[47a9600 fix const to let]
2. Darwin x64 version 14.5.0 memory 703/16384 MB
3. Docker: false
4. Node version: v7.0.0

Steps to reproduce the behavior (and fixes, if any)

I'm trying to save contact.name() in json, but when name contain emoji, contact.name() get something like this: 李佳芮 and json cannot read it properly.

Could you help me give me a method to get just contact name without emoji? Then I can deal with jsonfile successfully. thanks

For now , I use the following method, but I don't think it's a good way

  const tmp = (from as any).obj.name

  console.log(tmp.replace(/<(?:.|\n)*?>/gm, ''))

Paste the full output logs here with WECHATY_LOG=silly set

code as follows:

import {Wechaty} from '../../'

const bot = Wechaty.instance({profile:"test"})

bot
.on('scan',(url,code)=>{
    console.log(url)
})

.on('login',user=>{
    console.log(user.name())
})

.on('message',async function(m){
  const from = m.from()
  console.log(from)
  console.log(from.name())
})

.init()

SILL Message constructor() SN:0
SILL Message ready()
SILL Contact constructor(@2dbf6f0f8e957f04fdf55957342f2293)
SILL Contact ready()
SILL Contact get contact via PuppetWeb
SILL PuppetWebBridge getContact() retryPromise: attampt 1/35 time for timeout 306250
VERB PuppetWebBridge proxyWechaty(getContact, @2dbf6f0f8e957f04fdf55957342f2293)
SILL PuppetWebBridge execute()
SILL PuppetWebBrowser Browser.execute("return typeof WechatyBro === "undefined"")
SILL StateMonitor Browser:target() - open
SILL StateMonitor Browser:current() - open
SILL PuppetWebBridge execute()
SILL PuppetWebBrowser Browser.execute(" const callback = arguments[arguments.length - 1] const isAsync = (typeof ... ")
SILL StateMonitor Browser:target() - open
SILL StateMonitor Browser:current() - open
SILL Contact contactGetter(@2dbf6f0f8e957f04fdf55957342f2293) resolved
SILL Contact ready()
SILL Message ready()
SILL Contact ready()
SILL Contact ready()
Contact {
id: '@2dbf6f0f8e957f04fdf55957342f2293',
rawObj:
{ '$$hashKey': '010',
Alias: 'ruirui_0914',
AppAccountFlag: 0,
AttrStatus: 2147584103,
ChatRoomId: 0,
City: '海淀',
ContactFlag: 3,
DisplayName: '',
EncryChatRoomId: '',
HeadImgUrl: '/cgi-bin/mmwebwx-bin/webwxgeticon?seq=648940516&username=@2dbf6f0f8e957f04fdf55957342f2293&skey=@crypt_832129a3_e3f9e80c22e778ab18f378b6f4f612e3',
HideInputBarFlag: 0,
KeyWord: 'qq5',
MMOrderSymbol: 'LIJIARUISPANCLASSEMOJIEMOJI1F633SPAN',
MemberCount: 0,
MemberList: [],
NickName: '李佳芮',
OwnerUin: 0,
PYInitial: 'LJRSPANCLASSEMOJIEMOJI1F633SPAN',
PYQuanPin: 'lijiaruispanclassemojiemoji1f633span',
Province: '北京',
RemarkName: '',
RemarkPYInitial: '',
RemarkPYQuanPin: '',
Sex: 2,
Signature: '回山洞里',
SnsFlag: 49,
StarFriend: 0,
Statues: 0,
Uin: 0,
UniFriend: 0,
UserName: '@2dbf6f0f8e957f04fdf55957342f2293',
VerifyFlag: 0,
_h: 50,
_index: 373,
_offsetTop: 18312,
stranger: false },
obj:
{ id: '@2dbf6f0f8e957f04fdf55957342f2293',
uin: 0,
weixin: 'ruirui_0914',
name: '李佳芮',
remark: '',
sex: 2,
province: '北京',
city: '海淀',
signature: '回山洞里',
address: 'ruirui_0914',
star: false,
stranger: false } }
李佳芮

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions