Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Commit

Permalink
Update CiscoSparkbot.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Brown authored Oct 10, 2017
1 parent 4b8e29c commit 01c5879
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/CiscoSparkbot.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,14 +175,15 @@ function Sparkbot(configuration) {
message.user = decrypted_message.personEmail;
message.channel = decrypted_message.roomId;
message.text = decrypted_message.text;
message.html = decrypted_message.html;
message.id = decrypted_message.id;

// remove @mentions of the bot from the source text before we ingest it
if (message.raw_message.html) {
if (message.html) {

// strip the mention & HTML from the message
var pattern = new RegExp('^(\<p\>)?\<spark\-mention .*?data\-object\-id\=\"' + controller.identity.id + '\".*\>.*?\<\/spark\-mention\>', 'im');
if (!message.raw_message.html.match(pattern)) {
if (!message.html.match(pattern)) {
var encoded_id = controller.identity.id;
var decoded = new Buffer(encoded_id, 'base64').toString('ascii');

Expand All @@ -192,7 +193,7 @@ function Sparkbot(configuration) {
pattern = new RegExp('^(\<p\>)?\<spark\-mention .*?data\-object\-id\=\"' + matches[1] + '\".*\>.*?\<\/spark\-mention\>', 'im');
}
}
var action = message.raw_message.html.replace(pattern, '');
var action = message.html.replace(pattern, '');


// strip the remaining HTML tags
Expand Down

0 comments on commit 01c5879

Please sign in to comment.