Comparing version 1.1.8 to 2.0.0-beta
{ | ||
"extends": "eslint:recommended", | ||
"parserOptions": { | ||
"ecmaVersion": 6 | ||
"ecmaVersion": 2017 | ||
}, | ||
@@ -11,5 +11,9 @@ "env": { | ||
"rules": { | ||
"no-await-in-loop": "warn", | ||
"no-compare-neg-zero": "error", | ||
"no-extra-parens": ["warn", "all", { | ||
"nestedBinaryExpressions": false | ||
}], | ||
"no-template-curly-in-string": "error", | ||
"no-unsafe-negation": "error", | ||
"valid-jsdoc": ["error", { | ||
@@ -19,3 +23,3 @@ "requireReturn": false, | ||
"prefer": { | ||
"return": "return", | ||
"return": "returns", | ||
"arg": "param" | ||
@@ -27,2 +31,3 @@ }, | ||
"Boolean": "boolean", | ||
"Symbol": "symbol", | ||
"object": "Object", | ||
@@ -40,3 +45,3 @@ "function": "Function", | ||
"complexity": "warn", | ||
"consistent-return": "error", | ||
"consistent-return": "off", | ||
"curly": ["error", "multi-line", "consistent"], | ||
@@ -56,3 +61,4 @@ "dot-location": ["error", "property"], | ||
"no-octal-escape": "error", | ||
"no-return-assign": "error", | ||
"no-return-assign": "off", | ||
"no-return-await": "error", | ||
"no-self-compare": "error", | ||
@@ -65,5 +71,8 @@ "no-sequences": "error", | ||
"no-useless-concat": "error", | ||
"no-useless-escape": "off", | ||
"no-useless-escape": "error", | ||
"no-useless-return": "error", | ||
"no-void": "error", | ||
"no-warning-comments": "warn", | ||
"prefer-promise-reject-errors": "error", | ||
"require-await": "warn", | ||
"wrap-iife": "error", | ||
@@ -85,2 +94,3 @@ "yoda": "error", | ||
"brace-style": ["error", "1tbs", { "allowSingleLine": true }], | ||
"capitalized-comments": ["off", "always", { "ignoreConsecutiveComments": true }], | ||
"comma-dangle": ["error", "always-multiline"], | ||
@@ -99,5 +109,6 @@ "comma-spacing": "error", | ||
"max-depth": "error", | ||
"max-len": ["error", 120, 2], | ||
"max-nested-callbacks": ["error", { "max": 4 }], | ||
"max-statements-per-line": ["error", { "max": 2 }], | ||
"new-cap": "error", | ||
"new-cap": "off", | ||
"newline-per-chained-call": ["error", { "ignoreChainWithDepth": 3 }], | ||
@@ -114,2 +125,3 @@ "no-array-constructor": "error", | ||
"no-whitespace-before-property": "error", | ||
"nonblock-statement-body-position": "error", | ||
"object-curly-spacing": ["error", "always"], | ||
@@ -129,5 +141,7 @@ "operator-assignment": "error", | ||
"spaced-comment": "error", | ||
"template-tag-spacing": "error", | ||
"unicode-bom": "error", | ||
"arrow-body-style": "error", | ||
"arrow-parens": ["error", "always"], | ||
"arrow-spacing": "error", | ||
@@ -144,5 +158,4 @@ "no-duplicate-imports": "error", | ||
"template-curly-spacing": "error", | ||
"yield-star-spacing": "error", | ||
"no-console": "off" | ||
"yield-star-spacing": "error" | ||
} | ||
} |
{ | ||
"name": "retrocord", | ||
"version": "1.1.8", | ||
"description": "The best in life", | ||
"version": "2.0.0-beta", | ||
"description": "", | ||
"main": "src/index.js", | ||
"bin": { | ||
"retrocord": "src/index.js" | ||
}, | ||
"scripts": { | ||
"nexe": "node ./node_modules/nexe/bin/nexe" | ||
"lint": "eslint -c ./.eslintrc.json src", | ||
"build": "pkg ./package.json --out-path=./build", | ||
"full": "npm run lint && npm run build" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/devsnek/retrocord.git" | ||
}, | ||
"author": "snek <me@gus.host>", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/devsnek/retrocord/issues" | ||
}, | ||
"homepage": "https://github.com/devsnek/retrocord#readme", | ||
"dependencies": { | ||
"ansi-256-colors": "^1.1.0", | ||
"blessed": "github:devsnek/blessed", | ||
"chalk": "^2.0.1", | ||
"discord.js": "github:hydrabolt/discord.js", | ||
"inquirer": "^2.0.0", | ||
"node-emoji": "^1.4.3", | ||
"ora": "^1.0.0", | ||
"username": "^2.2.2", | ||
"vorpal": "^1.11.4" | ||
"erlpack": "github:hammerandchisel/erlpack", | ||
"node-emoji": "^1.8.1", | ||
"uws": "^8.14.0" | ||
}, | ||
"optionalDependencies": { | ||
"erlpack": "github:hammerandchisel/erlpack" | ||
}, | ||
"devDependencies": { | ||
"bufferutil": "^1.3.0", | ||
"nexe": "^1.1.2", | ||
"opusscript": "0.0.2", | ||
"utf-8-validate": "^2.0.0" | ||
"eslint": "^4.3.0", | ||
"pkg": "^4.1.3" | ||
}, | ||
"author": "Gus Caplan <me@gus.host>", | ||
"license": "MIT", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/GusCaplan/retrocord.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/GusCaplan/retrocord/issues" | ||
}, | ||
"homepage": "https://github.com/GusCaplan/retrocord#readme", | ||
"nexe": { | ||
"input": "./src/index.js", | ||
"output": "./build/retrocord^$", | ||
"temp": "tmp", | ||
"browserify": { | ||
"requires": [], | ||
"excludes": [], | ||
"paths": [] | ||
}, | ||
"runtime": { | ||
"framework": "node", | ||
"version": "latest", | ||
"js-flags": "--use_strict", | ||
"ignoreFlags": true | ||
} | ||
"bin": "./src/index.js", | ||
"pkg": { | ||
"scripts": "./src/**/*.js", | ||
"assets": "./assets/*" | ||
} | ||
} |
@@ -10,3 +10,3 @@ [](https://www.npmjs.com/package/retrocord) | ||
`npm i -g retrocord` | ||
`npm i -g retrocord` OR [download a release](/releases) | ||
@@ -17,6 +17,8 @@  | ||
__/search__ - master discord's new search endpoint before they do! | ||
__search__ - search a channel! | ||
__/shrug__ - just like the command in the official client, but cooler because it's in monospace! | ||
__shrug__ - just like the command in the official client, but cooler because it's in monospace! | ||
__/game__ - set the game you are playing! | ||
__game__ - set the game you are playing! | ||
__nick__ - set your nickname! |
232
src/index.js
@@ -1,189 +0,71 @@ | ||
#!/usr/bin/env node | ||
const logo = `______ _____ ___________ _____ _____ _________________ | ||
| ___ \\ ___|_ _| ___ \\ _ / __ \\ _ | ___ \\ _ \\ | ||
| |_/ / |__ | | | |_/ / | | | / \\/ | | | |_/ / | | | | ||
| /| __| | | | /| | | | | | | | | /| | | | | ||
| |\\ \\| |___ | | | | \\ \\ \\_/ / \\__/\\ \\_/ / |\\ \\| |/ / | ||
\\_| \\_\\____/ \\_/ \\_| \\_|\\___/ \\____/\\___/\\_| \\_|___/ | ||
The best in life | ||
`; | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const Discord = require('discord.js'); | ||
const vorpal = require('vorpal')(); | ||
const spinner = require('ora')('Loading...').start(); | ||
const center = require('./util/center'); | ||
const hexToRgb = require('./util/hexToRgb'); | ||
const chalk = vorpal.chalk; | ||
const colors = require('ansi-256-colors'); | ||
const emoji = require('node-emoji'); | ||
const LocalStorage = require('node-localstorage').LocalStorage; | ||
const getTermInfo = require('./util/getTermInfo'); | ||
const Storage = require('./Storage'); | ||
const gui = require('./gui'); | ||
const commands = require('./commands'); | ||
const assets = require('./assets'); | ||
const discord = require('./discord'); | ||
const lp = (v, n, c = '0') => String(v).length >= n ? `${v}` : (String(c).repeat(n) + v).slice(-n); | ||
const ctx = { | ||
gui, assets, | ||
discord: discord.client, | ||
allowInput: false, | ||
current: { | ||
scope: null, | ||
channel: null, | ||
}, | ||
}; | ||
const timestamp = vorpal.timestamp = (d = new Date(), mdy = false) => | ||
`${mdy ? `${lp(d.getFullYear().toString(), 2)}-${lp((d.getMonth() + 1).toString(), 2)}-${lp(d.getDate().toString(), 2)} ` : ''} | ||
${lp(d.getHours().toString(), 2)}: | ||
${lp(d.getMinutes().toString(), 2)}: | ||
${lp(d.getSeconds().toString(), 2)} | ||
`.replace(/\n/g, ''); | ||
const logMessage = vorpal.logMessage = (message) => { | ||
let name = message.author.username; | ||
let color = (...x) => colors.fg.getRgb(5, 5, 5) + x.join(' ') + colors.reset; | ||
let content = message.content; | ||
for (const mention of message.mentions.users.values()) { | ||
if (mention.id === client.user.id) { | ||
content = content.replace(new RegExp(`<@!?${mention.id}>`, 'g'), chalk.red.bold(`@${client.user.username}`)); | ||
process.stdout.write('\x07'); | ||
} else { | ||
content = content.replace(new RegExp(`<@!?${mention.id}>`, 'g'), `@${mention.username}`); | ||
gui.on('input', (message) => { | ||
if (message.startsWith(':')) { | ||
const [command, ...args] = message.slice(1).split(' '); | ||
if (command in commands) commands[command].run(ctx, args); | ||
} else { | ||
if (!ctx.allowInput) return; | ||
const args = message.split(' '); | ||
for (const word in args) { | ||
if (args[word].startsWith('@')) { | ||
const [username, discrim] = args[word].split('#').map((x) => x.replace('@', '').toLowerCase()); | ||
let user = ctx.discord.users.find((u) => { | ||
let match = false; | ||
if (u.username.replace(/ /g, '').toLowerCase() === username) match = true; | ||
if (discrim && u.discriminator !== discrim) match = false; | ||
return match; | ||
}); | ||
if (user) args[word] = user.toString(); | ||
} | ||
} | ||
} | ||
message = args.join(' '); | ||
if (message.member) { | ||
color = (...x) => { | ||
const role = message.member.roles.filter(r => r.color !== 0).last(); | ||
if (!role) return colors.fg.getRgb(5, 5, 5) + x.join(' ') + colors.reset; | ||
const c = hexToRgb(role.hexColor); | ||
return colors.fg.getRgb(c.r, c.g, c.b) + x.join(' ') + colors.reset; | ||
}; | ||
} | ||
for (const match of content.match(/:[^:]+:/g) || []) content = content.replace(match, emoji.get(match)); | ||
if (message.type !== 'DEFAULT') { | ||
switch (message.type) { | ||
case 'RECIPIENT_ADD': | ||
break; | ||
case 'RECIPIENT_REMOVE': | ||
break; | ||
case 'CALL': | ||
break; | ||
case 'CHANNEL_NAME_CHANGE': | ||
break; | ||
case 'CHANNEL_ICON_CHANGE': | ||
break; | ||
case 'PINS_ADD': | ||
vorpal.log(`${chalk.yellow(timestamp(message.createdAt))} ${color(`${name}#${message.author.discriminator}`)} ${chalk.bold('pinned a message!')}`); | ||
break; | ||
default: | ||
break; | ||
const customEmojis = getEmojis(); | ||
for (const match of message.match(/:[^:]+:/g) || []) { | ||
if (customEmojis) { | ||
const found = customEmojis.find((x) => x.name.toLowerCase() === match.replace(/:/g, '').toLowerCase()); | ||
message = message.replace(match, found ? found.toString() : null || emoji.get(match)); | ||
if (!found) message = message.replace(match, emoji.get(match)); | ||
} else { | ||
message = message.replace(match, emoji.get(match)); | ||
} | ||
} | ||
} else { | ||
vorpal.log(`${chalk.yellow(timestamp(message.createdAt))} ${color(`${name}#${message.author.discriminator}`)} ${content}`); | ||
} | ||
if (message.author.id !== client.user.id) message.acknowledge(); | ||
}; | ||
const client = vorpal.discord = new Discord.Client(); | ||
const termInfo = getTermInfo(); | ||
const DELIMITER = termInfo.font.toLowerCase().includes('nerd') ? '' : '>'; | ||
function getOSStoragePath() { | ||
switch (process.platform) { | ||
case 'darwin': | ||
return `${process.env.HOME}/Library/Application Support/retrocord`; | ||
case 'win32': | ||
return `${process.env.APPDATA}\\retrocord`; | ||
case 'linux': | ||
return `${process.env.HOME}/.retrocord`; | ||
default: | ||
return '.'; | ||
if (ctx.current.channel) ctx.current.channel.send(message); | ||
} | ||
} | ||
}); | ||
const OS_STORAGE_PATH = getOSStoragePath(); | ||
gui.init(); | ||
gui.put(`{center}${assets.logo}{/center}`, { center: true }); | ||
if (!fs.existsSync(OS_STORAGE_PATH)) { | ||
console.warn(`\nNew storage cache in \`${OS_STORAGE_PATH}\``); | ||
fs.mkdirSync(OS_STORAGE_PATH); | ||
if (Storage.has('token')) { | ||
discord.run(ctx); | ||
} else { | ||
gui.put('{bold}Please Login!{/bold}', { center: true }); | ||
} | ||
const LOCALSTORAGE_PATH = path.join(OS_STORAGE_PATH, 'cache'); | ||
if (!fs.existsSync(LOCALSTORAGE_PATH)) fs.mkdirSync(LOCALSTORAGE_PATH); | ||
const localStorage = new LocalStorage(LOCALSTORAGE_PATH); | ||
vorpal.current = {}; | ||
vorpal.find('help').remove(); | ||
vorpal.find('exit').remove(); | ||
require('./commands/help')(vorpal); | ||
require('./commands/join')(vorpal); | ||
require('./commands/nick')(vorpal); | ||
require('./commands/search')(vorpal); | ||
require('./commands/shrug')(vorpal); | ||
require('./commands/catcher')(vorpal); | ||
require('./commands/game')(vorpal); | ||
vorpal.command('/exit', 'exit').action(() => { | ||
vorpal.log('bye!'); | ||
process.exit(0); | ||
}); | ||
vorpal.command('/login <token>') | ||
.action((args, cb) => { | ||
localStorage.setItem('token', args.token); | ||
vorpal.log(chalk.bold('Token saved, use /logout to log out, or /exit to exit')); | ||
client.login(args.token).then(() => cb()).catch(() => { | ||
localStorage.removeItem('token'); | ||
vorpal.log(chalk.bold('INVALID TOKEN!')); | ||
client.destroy(); | ||
process.exit(); | ||
}); | ||
}); | ||
vorpal.command('/logout') | ||
.action((args, cb) => { | ||
localStorage.removeItem('token'); | ||
client.destroy(); | ||
process.exit(); | ||
return cb(); | ||
}); | ||
client.on('message', message => { | ||
if (message.channel.id !== vorpal.current.channel) return; | ||
if (client.user.blocked.has(message.author.id)) return; | ||
logMessage(message); | ||
}); | ||
client.once('ready', () => { | ||
spinner.stop(); | ||
if (client.user.bot) { | ||
vorpal.log(chalk.yellow.bold('NO BOTS')); | ||
localStorage.removeItem('token'); | ||
client.destroy(); | ||
process.exit(); | ||
function getEmojis() { | ||
if (ctx.discord.user && ctx.discord.user.premium) { | ||
return ctx.discord.emojis; | ||
} else if (ctx.current.scope && ctx.current.scope !== 'dm') { | ||
return ctx.current.scope.emojis; | ||
} else { | ||
return null; | ||
} | ||
console.log(center(logo)); | ||
console.log(center(`Connected as ${client.user.username}#${client.user.discriminator}`)); | ||
if (client.user.premium) console.log(center(' 🎉 with Discord Nitro! 🎉')); | ||
console.log('\n'); | ||
vorpal.delimiter(DELIMITER).show(); | ||
}); | ||
vorpal.history('retrocord'); | ||
let token = localStorage.getItem('token'); | ||
if (!token) { | ||
spinner.stop(); | ||
vorpal.delimiter(DELIMITER).show(); | ||
vorpal.log(chalk.bold('You are not logged in, please use the login command!')); | ||
} else { | ||
client.login(token).catch(() => { | ||
localStorage.removeItem('token'); | ||
vorpal.log(chalk.bold('INVALID TOKEN!')); | ||
client.destroy(); | ||
process.exit(); | ||
}); | ||
} | ||
process.on('unhandledRejection', () => {}); // eslint-disable-line no-empty-function |
@@ -1,18 +0,15 @@ | ||
const map = (number, inMin, inMax, outMin, outMax) => (number - inMin) * (outMax - outMin) / (inMax - inMin) + outMin; | ||
const SHORTHAND_RE = /^#?([a-f\d])([a-f\d])([a-f\d])$/i; | ||
module.exports = (hex) => { | ||
// Expand shorthand form (e.g. "03F") to full form (e.g. "0033FF") | ||
const shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i; | ||
hex = hex.replace(shorthandRegex, (m, r, g, b) => { | ||
return r + r + g + g + b + b; | ||
}); | ||
// Expand shorthand form (e.g. '03F') to full form (e.g. "0033FF") | ||
hex = hex.replace(SHORTHAND_RE, (m, r, g, b) => r + r + g + g + b + b); | ||
const mapRGB = (x) => Math.round(map(x, 0, 255, 0, 5)); | ||
const mapRGB = (x) => Math.round(x * 5 / 255); | ||
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex); | ||
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex); | ||
return result ? { | ||
r: mapRGB(parseInt(result[1], 16)), | ||
g: mapRGB(parseInt(result[2], 16)), | ||
b: mapRGB(parseInt(result[3], 16)) | ||
b: mapRGB(parseInt(result[3], 16)), | ||
} : null; | ||
} | ||
}; |
Sorry, the diff of this file is not supported yet
GitHub dependency
Supply chain riskContains a dependency which resolves to a GitHub URL. Dependencies fetched from GitHub specifiers are not immutable can be used to inject untrusted code or reduce the likelihood of a reproducible install.
Found 2 instances in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Copyleft License
License(Experimental) Copyleft license information was found.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
Non-permissive License
License(Experimental) A license not known to be considered permissive was found.
Found 1 instance in 1 package
7
2
0
100
23
1
19186
15
519
2
3
+ Addedchalk@^2.0.1
+ Addeduws@^8.14.0
+ Addeduws@8.14.1(transitive)
- Removedinquirer@^2.0.0
- Removedora@^1.0.0
- Removedusername@^2.2.2
- Removedvorpal@^1.11.4
- Removedansi-escapes@1.4.0(transitive)
- Removedansi-regex@2.1.13.0.1(transitive)
- Removedansi-styles@2.2.1(transitive)
- Removedbabel-polyfill@6.26.0(transitive)
- Removedbabel-runtime@6.26.0(transitive)
- Removedbuffer-from@1.1.2(transitive)
- Removedchalk@1.1.3(transitive)
- Removedcli-cursor@1.0.22.1.0(transitive)
- Removedcli-spinners@1.3.1(transitive)
- Removedcli-width@1.1.12.2.1(transitive)
- Removedcode-point-at@1.1.0(transitive)
- Removedconcat-stream@1.6.2(transitive)
- Removedcore-js@2.6.12(transitive)
- Removedcore-util-is@1.0.3(transitive)
- Removedcross-spawn-async@2.2.5(transitive)
- Removedexeca@0.4.0(transitive)
- Removedexit-hook@1.1.1(transitive)
- Removedextend@3.0.2(transitive)
- Removedexternal-editor@1.1.1(transitive)
- Removedfigures@1.7.02.0.0(transitive)
- Removedhas-ansi@2.0.0(transitive)
- Removedin-publish@2.0.1(transitive)
- Removedinherits@2.0.4(transitive)
- Removedinquirer@0.11.02.0.0(transitive)
- Removedis-fullwidth-code-point@1.0.02.0.0(transitive)
- Removedis-stream@1.1.0(transitive)
- Removedisarray@1.0.0(transitive)
- Removedisexe@2.0.0(transitive)
- Removedlodash@3.10.1(transitive)
- Removedlog-symbols@2.2.0(transitive)
- Removedlog-update@1.0.2(transitive)
- Removedlru-cache@4.1.5(transitive)
- Removedmem@0.1.1(transitive)
- Removedmimic-fn@1.2.0(transitive)
- Removedminimist@1.2.8(transitive)
- Removedmute-stream@0.0.50.0.6(transitive)
- Removednode-localstorage@0.6.0(transitive)
- Removednpm-run-path@1.0.0(transitive)
- Removednumber-is-nan@1.0.1(transitive)
- Removedobject-assign@4.1.1(transitive)
- Removedonce@1.4.0(transitive)
- Removedonetime@1.1.02.0.1(transitive)
- Removedora@1.4.0(transitive)
- Removedos-shim@0.1.3(transitive)
- Removedos-tmpdir@1.0.2(transitive)
- Removedpath-key@1.0.0(transitive)
- Removedpinkie@2.0.4(transitive)
- Removedpinkie-promise@2.0.1(transitive)
- Removedprocess-nextick-args@2.0.1(transitive)
- Removedpseudomap@1.0.2(transitive)
- Removedreadable-stream@2.3.8(transitive)
- Removedreadline2@1.0.1(transitive)
- Removedregenerator-runtime@0.10.50.11.1(transitive)
- Removedrestore-cursor@1.0.12.0.0(transitive)
- Removedrun-async@0.1.02.4.1(transitive)
- Removedrx@4.1.0(transitive)
- Removedrx-lite@3.1.2(transitive)
- Removedsafe-buffer@5.1.2(transitive)
- Removedsignal-exit@3.0.7(transitive)
- Removedspawn-sync@1.0.15(transitive)
- Removedstring-width@1.0.22.1.1(transitive)
- Removedstring_decoder@1.1.1(transitive)
- Removedstrip-ansi@3.0.14.0.0(transitive)
- Removedstrip-eof@1.0.0(transitive)
- Removedsupports-color@2.0.0(transitive)
- Removedthrough@2.3.8(transitive)
- Removedtmp@0.0.29(transitive)
- Removedtypedarray@0.0.6(transitive)
- Removedusername@2.3.0(transitive)
- Removedutil-deprecate@1.0.2(transitive)
- Removedvorpal@1.12.0(transitive)
- Removedwhich@1.3.1(transitive)
- Removedwrap-ansi@2.1.0(transitive)
- Removedwrappy@1.0.2(transitive)
- Removedyallist@2.1.2(transitive)
Updatednode-emoji@^1.8.1