Skip to content

Commit

Permalink
Drop adding duplicate messages
Browse files Browse the repository at this point in the history
  • Loading branch information
EXL committed Oct 19, 2018
1 parent adb199f commit ecc13d0
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions DigestBot.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ bot.on('text', function(msg)

// console.log(msg);

if (msg.forward_date) { // Skip All Forward Messages
if (msg.forward_date) { // Skip All Forwarded Messages
return;
}

Expand All @@ -265,7 +265,9 @@ bot.on('text', function(msg)
's_username': messageUserName
};

globalStackListDigestMessages.push(messageInfoStruct);
if (!isDuplicateMessage(messageInfoStruct)) {
globalStackListDigestMessages.push(messageInfoStruct);
}

// Send message by bot.
sendMessageByBot(messageChatId,
Expand Down Expand Up @@ -1047,6 +1049,18 @@ function addYourStringToString(aYourString, aString)
return aYourString + aString;
}

function isDuplicateMessage(aMessage)
{
for (var i = 0; i < globalStackListDigestMessages.length; ++i) {
if (aMessage.s_message === globalStackListDigestMessages[i].s_message &&
aMessage.s_username === globalStackListDigestMessages[i].s_username &&
aMessage.s_date === globalStackListDigestMessages[i].s_date) {
return true;
}
}
return false;
}

// ----- CURRENCY SECTION
function createReportCurrencyHeader(aCatchPhrase)
{
Expand Down

0 comments on commit ecc13d0

Please sign in to comment.