MCPcopy
hub / github.com/wechaty/wechaty / talker

Method talker

src/user/message.ts:254–273  ·  view source on GitHub ↗

* Get the talker of a message. * @returns {Contact} * @example * const bot = new Wechaty() * bot * .on('message', async m => { * const talker = msg.talker() * const text = msg.text() * const room = msg.room() * if (room) { * const topic = await room.topic()

()

Source from the content-addressed store, hash-verified

252 * .start()
253 */
254 public talker (): Contact {
255 if (!this.payload) {
256 throw new Error('no payload')
257 }
258
259 // if (contact) {
260 // this.payload.from = contact
261 // return
262 // }
263
264 const fromId = this.payload.fromId
265 if (!fromId) {
266 // Huan(202011): It seems that the fromId will never be null?
267 // return null
268 throw new Error('payload.fromId is null?')
269 }
270
271 const from = this.wechaty.Contact.load(fromId)
272 return from
273 }
274
275 /**
276 * Use `message.talker()` to replace `message.from()` #2094

Callers 6

toStringMethod · 0.95
conversationMethod · 0.95
fromMethod · 0.95
sayMethod · 0.95
selfMethod · 0.95
message.spec.tsFile · 0.80

Calls 1

loadMethod · 0.45

Tested by

no test coverage detected