Twitch流状态显示在线.当用户离线时
Twitch stream status is showing online. while user is offline
我在NODE JS中编写了一个bot,它将持续监控twitch用户,当一些用户在线时,它将发送消息给"group me"应用程序,该用户在线。它工作得很好。我的问题是,有时它发送的消息,用户是在线的,但实际上用户是离线的。知道怎么解决这个问题吗?
见截图
var users = ["Statelinejay", "Ad_914", "Houssam06" ];
var messages = ["notsent", "notsent", "notsent" ];
var Client = require('node-rest-client').Client;
var client = new Client();
var express = require('express');
var request = require('request');
var app = express();
app.set('port', (process.env.PORT || 5000));
function theCall(index) {
console.log('Processing ' + users[index]);
client.get('https://api.twitch.tv/kraken/streams/' + users[index] + '?client_id=xxxxxxxxxxxxxxxxxxxxxxx', function (data, response) {
if (data["stream"] === null) {
messages[index] = 'notsent';
console.log(users[index] + 'is offline');
} else
//// Start of sending message
var myJSONObject = {
"bot_id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"text": " https://www.twitch.tv/" + users[index]
};
if (messages[index] === 'notsent') {
request.post({
url: " https://api.groupme.com/v3/bots/post",
method: "POST",
json: true, // <--Very important!!!
body: myJSONObject
},
function (error, response, body) {
console.log(error);
}
);
messages[index] = 'sent';
console.log('message sent');
}
//// End of sending message
console.log(users[index] + ' is online') ;
}
theCall((++index % users.length));
});
}
app.listen(app.get('port'), function() {
console.log('Node app is running on port', app.get('port'));
theCall(0);
});
你确定数据["流"]总是空每当流是离线的?它可以没有定义吗?你能不能试试
if (!data["stream"])
代替
if (data["stream"] === null)
?
如果这不起作用,你可以console.log你的数据和响应变量的假在线流,并更新问题吗?
相关文章:
- 使用acess代币登录Facebook,并通过网络应用程序离线发布
- 回调函数在python代码中离线
- web浏览器中的离线应用程序存储数据并在之后上传
- OSM-离线查询我的IONIC/CORDOVA项目
- 访问离线jquery应用程序中的本地文件
- 独立离线的html5网络应用程序
- 如果没有互联网连接,Android WebView离线消息
- 如何离线存储数据库,在线时共享到服务器
- qoxdoo中的离线存储是否与所有浏览器和本地文件系统兼容
- Chrome离线不会使用cache.manifest
- 使用jquery将html文件加载到html中,用于离线/本地项目
- 在 Meteor.loginWithPassword 之后,旧用户不会离线(meteor-user-status 包)
- 当用户离线时使用角度 js 返回缓存响应
- 在twitch tv javascript中显示离线用户
- 为用户提供离线HTML5 web应用程序的访问权限
- node . js,套接字.Io:检查用户是否在线或离线
- 是否有可能在javascript中离线服务用户创建的内容
- Twitch流状态显示在线.当用户离线时
- 在线和离线用户实时使用strophe.js
- 如何使用socketio实时显示在线/离线用户使用帆船