-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
乱码 #1656
Comments
@lijiarui 帮忙看看呗 |
Need More InformationI suggest you not follow the ISSUE Template, this issue doesn't have enough information about your problem. In order to help us to find the problem out, you should provide all the detail information about the issue. Please make sure you are following the ISSUE Template, answer all the question, and the more important: provide the steps to reproduce the problem. |
需要什么信息?我发你。 |
Please follow the ISSUE Template : 0. Report Issue Guide
1. Expected behaviorQuestion: What behavior do you expect? Answer: 2. Actual behaviorQuestion: What actual behavior did you experience? Answer: 3. Steps to reproduce your problem (and fixes, if any)This part is very important: if you can not provide any reproduce steps, then the problem will be very hard to be recognized. Question: What're the reproducible steps for us to see your problem? Answer: 4. Full Output LogsShow Logs$ WECHATY_LOG=silly node yourbot.js
Question: Paste your FULL(DO NOT ONLY PROVIDE FRAGMENTS) log messages
Answer:
|
Question: What behavior do you expect? Answer:机器人发消息,对方收到是乱码
Question: What actual behavior did you experience? Answer:第一次使用,在自己window server电脑上安装node js,安装git,然后用git安装wechaty: const {
Wechaty,
config,
} = require('wechaty')
function onScan (qrcode, status) {
require('qrcode-terminal').generate(qrcode, { small: true }) // show qrcode on console
const qrcodeImageUrl = [
'https://api.qrserver.com/v1/create-qr-code/?data=',
encodeURIComponent(qrcode),
].join('')
console.log(qrcodeImageUrl)
}
function onLogin (user) {
console.log(`${user} login`)
}
function onLogout(user) {
console.log(`${user} logout`)
}
async function onMessage (msg) {
console.log(msg.toString())
let msgText = msg.text()
if (msgText.indexOf("vip") > -1) {
respText ='想成为VIP?'
await msg.say(respText)
}
}
const bot = new Wechaty({
profile: config.default.DEFAULT_PROFILE,
})
bot.on('scan', onScan)
bot.on('login', onLogin)
bot.on('logout', onLogout)
bot.on('message', onMessage)
bot.start()
.then(() => console.log('Starter Bot Started.'))
.catch(e => console.error(e)) 然后执行npm start 然后用微信登陆发消息,发送包含vip的消息
This part is very important: if you can not provide any reproduce steps, then the problem will be very hard to be recognized. Question: What're the reproducible steps for us to see your problem? Answer::第一次使用,在自己window server电脑上安装node js,安装git,然后用git安装wechaty: const {
Wechaty,
config,
} = require('wechaty')
function onScan (qrcode, status) {
require('qrcode-terminal').generate(qrcode, { small: true }) // show qrcode on console
const qrcodeImageUrl = [
'https://api.qrserver.com/v1/create-qr-code/?data=',
encodeURIComponent(qrcode),
].join('')
console.log(qrcodeImageUrl)
}
function onLogin (user) {
console.log(`${user} login`)
}
function onLogout(user) {
console.log(`${user} logout`)
}
async function onMessage (msg) {
console.log(msg.toString())
let msgText = msg.text()
if (msgText.indexOf("vip") > -1) {
respText ='想成为VIP?'
await msg.say(respText)
}
}
const bot = new Wechaty({
profile: config.default.DEFAULT_PROFILE,
})
bot.on('scan', onScan)
bot.on('login', onLogin)
bot.on('logout', onLogout)
bot.on('message', onMessage)
bot.start()
.then(() => console.log('Starter Bot Started.'))
.catch(e => console.error(e)) 然后执行npm start 然后用微信登陆发消息,发送包含vip的消息
|
@lijiarui 美女 |
Please paste the full log info, thanks :) |
|
Could you add async function onMessage (msg) {
console.log(msg.toString())
let msgText = msg.text()
if (msgText.indexOf("vip") > -1) {
respText ='想成为VIP?'
+ console.log(respText)
await msg.say(respText)
}
} |
改成上面代码,结果运行出错了
|
就是改成这样也是两行错误编码 async function onMessage (msg) {
console.log(msg.toString())
let msgText = msg.text()
if (msgText.indexOf("vip") > -1) {
let respText ='想成为VIP?'
console.log(respText)
await msg.say(respText)
await msg.say('甚至将他的')
}
} 运行结果:
|
Could you just try the following code: const a = '中文'
console.log(a) If this still has a strange code, I guess this is not related to wechaty, it is related to your code editor. |
Or related to windows encoding. |
解决了,谢谢美女和大神。果然是编辑器问题,我直接使用记事本的原因。 |
async function onMessage (msg) {
console.log(msg.toString())
let msgText = msg.text()
if (msgText.indexOf("vip") > -1) {
respText = "想成为VIP?"
await msg.say(respText)
}
}
微信端收到乱码:
���ΪVIP��
怎么解决?
The text was updated successfully, but these errors were encountered: