0
執行該代碼時,我得到一個錯誤的Twitter主題標籤:我有一個錯誤時,我恢復與eventMsg.entities.hashtags [0] .text區段
function TagEvent(eventMsg){
var Myname = eventMsg.in_reply_to_screen_name;
var Hashtag = eventMsg.entities.hashtags[0].text;
var Isname = eventMsg.user.screen_name;
var Info = {
Quote: Myname,
Sender: Isname,
UseHashtag: Hashtag
};
console.log(Info);
if(Myname == 'NameOfMyBot' && Hashtag == 'Pic'){
console.log("correct Hashtag");
T.post("statuses/update", {status:'@'+Isname+' reply test '}, tweeted);
}
和在CMD誤差爲:
C:\Users\Desktop\picsbot\bot.js:31
var Hashtag = eventMsg.entities.hashtags[0].text;
^
TypeError: Cannot read property 'text' of undefined
at StreamingAPIConnection.TagEvent (C:\Users\Desktop\picsbot\bot.js:31:46)
at emitOne (events.js:96:13)
at StreamingAPIConnection.emit (events.js:188:7)
at module.exports.<anonymous> (C:\Users\Desktop\picsbot\node_modules\twit\lib\streaming-api-connection.js:314:56)
at emitOne (events.js:96:13)
at module.exports.emit (events.js:188:7)
at module.exports.Parser.parse (C:\Users\Desktop\picsbot\node_modules\twit\lib\parser.js:47:16)
at Gunzip.<anonymous> (C:\Users\Desktop\picsbot\node_modules\twit\lib\streaming-api-connection.js:134:21)
at emitOne (events.js:96:13)
at Gunzip.emit (events.js:188:7)
at readableAddChunk (_stream_readable.js:176:18)
at Gunzip.Readable.push (_stream_readable.js:134:10)
at Gunzip.Transform.push (_stream_transform.js:128:32)
at Zlib.callback (zlib.js:584:14)
但是,推特仍然發佈之前,機器人關機,當我不執行該功能發佈,我沒有錯誤。
所以感謝它的工作,但我有一個小錯誤,他第二次運行我的代碼和#標籤是不確定的,但他不執行我的功能在twitter上發佈,所以它很奇怪,但它仍然工作。 – Mineck