Skip to content

Commit

Permalink
main: add sendStatus command and fix some bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Ali Mihandoost committed Jul 25, 2015
1 parent ff2c6f7 commit 09284bb
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,8 @@ onMessage = (msg) => {
}

// Send post
let text = fixNumbers((msg.text || '').trim());
let postId = parseInt(text.replace('/',''), 10);
let text = fixNumbers((msg.text || ''));
let postId = parseInt(text.replace('/','').trim(), 10);
if(postId > -1)
{
sendPost(msg.chat.id, postId);
Expand Down Expand Up @@ -235,6 +235,12 @@ onMessage = (msg) => {
uploadAudio(msg.chat.id, msg.text.replace('/uploadaudio ', '').trim());
}

// status
if(fromAdmin && (msg.text || '').trim().indexOf('/status ') === 0)
{
sendStatus(msg.chat.id);
}

//Notify other messages to admin
// msg.data = msgDate.toLocaleString();
if(!fromAdmin){
Expand Down Expand Up @@ -622,6 +628,21 @@ uploadAudio = (userId, path) => {
sendMessage(userId, debug);
});
notifyfn();
},

sendStatus = (userId) => {
let
status = 'postStatus: ',
postStatus = {}
;
for(let i=0; len = data.posts.lenhth; i<len; i++)
{
postStatus[`Cast_${i}`] = data.posts[i].sent_count;
}

status += JSON.stringify(postStatus, null, 2);

sendMessage(userId, status)
}

;
Expand Down

0 comments on commit 09284bb

Please sign in to comment.