Skip to content

Commit

Permalink
added code to prevent duplicated messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Cameron Henlin authored and Cameron Henlin committed Feb 7, 2015
1 parent 4335b87 commit 52685b8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
14 changes: 10 additions & 4 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ var LAST_SEEN_CHAT_ID = 0;
var ID_MISMATCH = false;
var SELECTED_CHATTER = "";
var MY_APPLE_ID = "";
var sending = false;

// blessed code
var chatList = blessed.list({
Expand Down Expand Up @@ -77,7 +78,7 @@ var outputBox = blessed.list({
// Possibly support:
// align: 'center',
fg: 'blue',
height: '80%',
height: '85%',
border: {
type: 'line'
},
Expand Down Expand Up @@ -299,22 +300,27 @@ function hasNewMessages() {
}

function sendMessage(to, message) {
if (sending) { return; }
sending = true;

if (to.indexOf('chat') > -1) {
applescript.execFile(__dirname+'/sendmessage.AppleScript', [[to.split('-chat')[0]], message], function(err, result) {
if (err) {
throw err;
}

screen.render();
});
sending = false;
}.bind(this));
} else {
applescript.execFile(__dirname+'/sendmessage_single.AppleScript', [[to], message], function(err, result) {
if (err) {
throw err;
}

screen.render();
});
sending = false;
}.bind(this));
}

}
Expand All @@ -335,4 +341,4 @@ setInterval(function() {
}
}.bind(this));
}.bind(this));
}, 250);
}, 250);
3 changes: 2 additions & 1 deletion sendmessage.AppleScript
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ on run argv
end tell
delay 0.1
keystroke item 1 of argv
delay 1.5
delay 2
key code 125
keystroke return
delay 0.1
keystroke tab
Expand Down

0 comments on commit 52685b8

Please sign in to comment.