From ab56bae8bfdb7999868139ae6b692ac70bafd9f3 Mon Sep 17 00:00:00 2001 From: ale Date: Thu, 19 Mar 2020 15:14:26 +0100 Subject: [PATCH] initial commit --- README.md | 17 +++++++++++++++++ package.json | 15 +++++++++++++++ record.js | 27 +++++++++++++++++++++++++++ records/.gitignore | 0 4 files changed, 59 insertions(+) create mode 100644 README.md create mode 100644 package.json create mode 100644 record.js create mode 100644 records/.gitignore diff --git a/README.md b/README.md new file mode 100644 index 0000000..80cca0a --- /dev/null +++ b/README.md @@ -0,0 +1,17 @@ +# mumble-record +## Mumble Record Bot in NodeJS + +# Install +``` +yarn or npm i +``` +# Run +``` +node record.js +``` +# Example +``` +node record.js mastodon.madrid record +``` +# License +MIT \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..cfffd8d --- /dev/null +++ b/package.json @@ -0,0 +1,15 @@ +{ + "name": "record", + "version": "1.0.0", + "description": "", + "main": "record.js", + "scripts": { + "install": "openssl req -newkey rsa:2048 -nodes -keyout key.pem -x509 -days 365 -out cert.pem" + }, + "dependencies": { + "lame": "*", + "mumble": "*" + }, + "author": "ale", + "license": "MIT" +} diff --git a/record.js b/record.js new file mode 100644 index 0000000..260a23a --- /dev/null +++ b/record.js @@ -0,0 +1,27 @@ +const mumble = require('mumble'), + fs = require('fs'), + lame = require('lame'), + options = { + key: fs.readFileSync(__dirname + '/key.pem'), + cert: fs.readFileSync(__dirname + '/cert.pem') + } + +console.log('Connecting') +mumble.connect(process.argv[2] || 'mastodon.madrid', options, (error, connection) => { + if (error) { console.error(error) } + console.log('Connected') + connection.authenticate(process.argv[3] || 'record') + connection.on('initialized', () => { + chan = connection.channelByName('Root') + chan.join() + }) + const encoder = new lame.Encoder({ + channels: 1, + sampleRate: 48000, + bitDepth: 16, + bitRate: 128, + outSampleRate: 44100, + mode: lame.STEREO + }) + connection.outputStream().pipe(encoder).pipe(fs.createWriteStream(__dirname + '/records/mumble-' + Date.now() + '.mp3')) +}) \ No newline at end of file diff --git a/records/.gitignore b/records/.gitignore new file mode 100644 index 0000000..e69de29