This repository has been archived by the owner on Jun 20, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bf4e23d
commit 3214a9e
Showing
8 changed files
with
115 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
[ | ||
"catch that man!", | ||
"with you", | ||
"with fire", | ||
"@everyone", | ||
"hide and seek", | ||
"nothing", | ||
"with bad code", | ||
"...", | ||
";D" | ||
"catch that man!", | ||
"with you", | ||
"with fire", | ||
"@everyone", | ||
"hide and seek", | ||
"nothing", | ||
"with bad code", | ||
"...", | ||
";D" | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[ | ||
"If someone says this, you will be notified!", | ||
"This too.", | ||
"Bananas" | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
Created by TheRacingLion (https://github.com/TheRacingLion) [ 14 / 03 / 2017 ] | ||
-*Read LICENSE to know more about permissions*- | ||
Keyword Notifier. Tracks specific keywords set in config and notifies them in the notification channel or in console. | ||
*/ | ||
const moment = require('moment') | ||
const keywords = require('../../config/keywords.json') | ||
|
||
module.exports = (self, log, config) => { | ||
self.on('messageCreate', (msg) => { | ||
if (!msg.author || !msg.channel.guild) return | ||
if (~config.keywordNotificator.ignoredServers.indexOf(msg.channel.guild.id)) return | ||
if (msg.author.id !== self.user.id && !msg.author.bot && keywords && keywords.length > 0) { | ||
for (let i = 0; i < keywords.length; i++) { | ||
let keyword = config.keywordNotificator.caseInsensitive ? ~msg.cleanContent.replace(/\n/g, ' ').toLowerCase().indexOf(keywords[i].toLowerCase()) : ~msg.content.indexOf(keywords[i]) | ||
if (keyword) { | ||
self.counts.keywordsGot = self.counts.keywordsGot + 1 | ||
if (!config.keywordNotificator.logBlockedUsers && self.relationships.has(msg.author.id)) { | ||
if (self.relationships.get(msg.author.id).type === 2) continue | ||
} | ||
if (config.keywordNotificator.inConsole) { log.keyword(msg, keywords[i]) } | ||
if (config.keywordNotificator.inNotificationChannel) { | ||
if (Object.keys(self.channelGuildMap).includes(config.notificationChannelID)) { | ||
self.getMessages(msg.channel.id, 4, msg.id).then(msgs => { | ||
self.createChannelWebhook(config.notificationChannelID, { name: msg.author.username }).then(w => { | ||
self.counts.msgsSent = self.counts.msgsSent + 1 | ||
self.executeWebhook(w.id, w.token, { | ||
username: msg.author.username, | ||
avatarURL: msg.author.avatarURL, | ||
content: `**I mentioned keyword \`${keywords[i]}\` in** ${msg.channel.mention}!`, | ||
embeds: [{ | ||
title: moment(msg.timestamp).format('ddd, Do of MMM @ HH:mm:ss'), | ||
author: { | ||
name: `${msg.author.username}#${msg.author.discriminator} (${msg.author.id})`, | ||
icon_url: msg.author.avatarURL | ||
}, | ||
color: 16426522, | ||
fields: [ | ||
{ name: msgs[2].author.username, value: msgs[2].cleanContent, inline: false }, | ||
{ name: msgs[1].author.username, value: msgs[1].cleanContent, inline: false }, | ||
{ name: msgs[0].author.username, value: msgs[0].cleanContent, inline: false }, | ||
{ name: msg.author.username, value: msg.cleanContent, inline: false }, | ||
{ name: 'Guild', value: `${msg.channel.guild.name}\n(${msg.channel.guild.id})`, inline: true }, | ||
{ name: 'Channel', value: `#${msg.channel.name}\n(${msg.channel.id})`, inline: true }, | ||
{ name: 'Msg', value: `(${msg.id})`, inline: true } | ||
] | ||
}] | ||
}).then(self.deleteWebhook(w.id, w.token)) | ||
}) | ||
}) | ||
} else { log.err('Invalid config, "notificationChannelID". Must be a channel ID from a server you are in.', 'Mention Stalker'); process.exit() } | ||
} | ||
return | ||
} | ||
continue | ||
} | ||
return | ||
} | ||
return | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters