提交 218fbfe0 编写于 作者: Huan (李卓桓)'s avatar Huan (李卓桓)

rename deprecated `content()` to `text()`

上级 6a92dac4
......@@ -166,7 +166,7 @@ const Talkers: Talker[] = []
function talk(m) {
const fromId = m.from().id
const roomId = m.room().id
const content = m.content()
const content = m.text()
const talkerName = fromId + roomId
if (!Talkers[talkerName]) {
......
......@@ -84,7 +84,7 @@ bot
+ `${m.from()}:${m}`,
)
if (/^(ding|ping|bing|code)$/i.test(m.content()) && !m.self()) {
if (/^(ding|ping|bing|code)$/i.test(m.text()) && !m.self()) {
m.say('dong')
log.info('Bot', 'REPLY: dong')
......
......@@ -31,7 +31,7 @@ export async function onMessage(this: Wechaty, message: Message): Promise<void>
try {
const room = message.room()
const sender = message.from()
const content = message.content()
const content = message.text()
console.log((room ? '[' + room.topic() + ']' : '')
+ '<' + sender.name() + '>'
......
......@@ -19,7 +19,7 @@
exports = module.exports = async function onMessage (message) {
const room = message.room();
const sender = message.from();
const content = message.content();
const content = message.text();
const topic = room ? '[' + room.topic() + ']' : '';
......
......@@ -34,7 +34,7 @@ export default async function onMessage (message) {
try {
const room = message.room()
const sender = message.from()
const content = message.content()
const content = message.text()
const roomName = room ? `[${room.topic()}] ` : ''
process.stdout.write(
......@@ -44,11 +44,11 @@ export default async function onMessage (message) {
saveMediaFile(message)
return
}
console.log(`${Misc.digestEmoji(message)}`)
// add an extra CR if too long
if (content.length > 80) console.log("")
const config = await hotImport('config.js')
// Hot import! Try to change the msgKW1&2 to 'ping' & 'pong'
// after the bot has already started!
......@@ -62,7 +62,7 @@ export default async function onMessage (message) {
}
} catch (e) {
log.error('Bot', 'on(message) exception: %s' , e)
}
}
}
async function saveMediaFile(message) {
......
......@@ -160,7 +160,7 @@ bot
.on('message', async function(this: Wechaty, message) {
const room = message.room()
const sender = message.from()
const content = message.content()
const content = message.text()
console.log((room ? '[' + room.topic() + ']' : '')
+ '<' + sender.name() + '>'
......
......@@ -82,10 +82,10 @@ bot
log.info('Bot', 'talk: %s' , msg)
try {
const {text: reply} = await tuling.ask(msg.content(), {userid: msg.from()})
const {text: reply} = await tuling.ask(msg.text(), {userid: msg.from()})
log.info('Tuling123', 'Talker reply:"%s" for "%s" ',
reply,
msg.content(),
msg.text(),
)
msg.say(reply)
} catch (e) {
......
......@@ -200,7 +200,7 @@ async function onMessage(
const topicRestul = await Firer.checkRoomTopic.call(this , m)
if (!joinResult && !leaveResult && !topicRestul) {
log.warn('PuppetPuppeteerEvent', `checkRoomSystem message: <${m.content()}> not found`)
log.warn('PuppetPuppeteerEvent', `checkRoomSystem message: <${m.text()}> not found`)
}
} else {
Firer.checkFriendConfirm.call(this, m)
......
......@@ -736,7 +736,7 @@ export class PuppetPuppeteer extends Puppet {
// const m = new Message()
// m.to('filehelper')
// m.content(content)
// m.text(content)
// return await this.send(m)
return await this.user.say(text)
......
......@@ -84,7 +84,7 @@ test('PuppetPuppeteerFriendRequest.confirm smoke testing', async t => {
wechaty: new Wechaty(),
})
t.true(/^You have added (.+) as your WeChat contact. Start chatting!$/.test(m.content()), 'should match confirm message')
t.true(/^You have added (.+) as your WeChat contact. Start chatting!$/.test(m.text()), 'should match confirm message')
const fr = new MyFriendRequest()
const contact = m.from()
......
......@@ -462,7 +462,7 @@ export class PuppeteerMessage extends Message {
// flatten array, see http://stackoverflow.com/a/10865042/1123955
const mentionList = [].concat.apply([], rawMentionedList)
log.verbose('PuppeteerMessage', 'mentioned(%s),get mentionList: %s', this.content(), JSON.stringify(mentionList))
log.verbose('PuppeteerMessage', 'mentioned(%s),get mentionList: %s', this.text(), JSON.stringify(mentionList))
contactList = [].concat.apply([],
mentionList.map(nameStr => room.memberAll(nameStr))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册