diff --git a/src/server.ts b/src/server.ts index 991a503..4cb18dd 100644 --- a/src/server.ts +++ b/src/server.ts @@ -17,7 +17,6 @@ interface IModuleMap { } let cachedModules: IModuleMap = {}; -let cachedTriggers: any[] = []; const client = new discord.Client(); const mediaUsers = new Map(); @@ -173,18 +172,6 @@ client.on('message', message => { } } catch (err) { logger.error(err); } - } else if (message.author.bot === false) { - // This is a normal channel message. - cachedTriggers.forEach(function (trigger) { - if (!trigger.roles || findArray(message.member.roles.cache.map(x => x.name), trigger.roles)) { - if (trigger.trigger(message) === true) { - logger.debug(`${message.author.username} ${message.author} [Channel: ${message.channel}] triggered: ${message.content}`); - try { - trigger.execute(message); - } catch (err) { logger.error(err); } - } - } - }); } }); @@ -202,9 +189,6 @@ fs.readdirSync('./commands/').forEach(function (file) { } }); -// Cache all triggers. -cachedTriggers = []; - data.readWarnings(); data.readBans(); diff --git a/src/triggers/github.js b/src/triggers/github.js deleted file mode 100644 index 8c46989..0000000 --- a/src/triggers/github.js +++ /dev/null @@ -1,45 +0,0 @@ -const request = require('request'); - -const regex = /[^<\\]#(\d+)/ig; - -exports.trigger = function (message) { - return new RegExp(regex).test(message.content); -}; - -exports.execute = function (message) { - let matcher = new RegExp(regex); - let match = matcher.exec(message.content); - let matched = []; - let threshold = process.env.GITHUB_OLD_THRESHOLD || 2000; - let repo = process.env.GITHUB_REPOSITORY || "citra-emu/citra"; - - while (match != null) { - if (matched.indexOf(match[1]) === -1) { - matched.push(match[1]); - } else { - match = matcher.exec(message.content); - continue; - } - - // We do not want to automatically match old issues / PRs. - // This usually happens when someone messes up pinging another person or - // in general conversation. - // ex: You're #1! - if (match[1] < threshold) { return; } - - // Map domain path to type - let map = {'pull': 'Pull Request', 'issues': 'Issue'}; - - let url = `https://github.com/${repo}/pull/${match[1]}`; - request(url, function (error, response, body) { - if (!error && response.statusCode === 200) { - // Set path to type of comment (issues/pull) - let path = response.request.uri.pathname.split('/')[3]; - - message.channel.send(`Github ${map[path]}: ${url}`); - } - }); - - match = matcher.exec(message.content); - } -};