Initial commit
Este commit está contenido en:
26
README.md
Archivo normal
26
README.md
Archivo normal
@@ -0,0 +1,26 @@
|
|||||||
|
# grumble-youtube
|
||||||
|
|
||||||
|
## Install
|
||||||
|
|
||||||
|
`npm i` or `yarn`
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```
|
||||||
|
$ MUMBLE_SERVER=server.domain.com node index.js
|
||||||
|
```
|
||||||
|
|
||||||
|
## Play
|
||||||
|
|
||||||
|
```
|
||||||
|
Write in grumble: play <youtube-link>
|
||||||
|
|
||||||
|
Example:
|
||||||
|
play https://www.youtube.com/watch?v=XXXXXXX
|
||||||
|
|
||||||
|
You can use other links sites such as youtube-dl software
|
||||||
|
```
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
### MIT
|
||||||
27
index.js
Archivo normal
27
index.js
Archivo normal
@@ -0,0 +1,27 @@
|
|||||||
|
const { NodeGrumble, Events, MessageType } = require('node-grumble'),
|
||||||
|
ytdl = require('ytdl-core'),
|
||||||
|
ytdlcore = require('youtube-dl'),
|
||||||
|
grumble = NodeGrumble.create({
|
||||||
|
url: String(process.env.MUMBLE_SERVER),
|
||||||
|
name: String('grumble-youtube'),
|
||||||
|
}),
|
||||||
|
volume = 0.6
|
||||||
|
|
||||||
|
console.log('Connecting');
|
||||||
|
(async () => {
|
||||||
|
grumble.on(Events.Connected, () => {
|
||||||
|
console.log('Connected to ' + process.env.MUMBLE_SERVER)
|
||||||
|
})
|
||||||
|
const connection = await grumble.connect()
|
||||||
|
grumble.on(MessageType.TextMessage, message => {
|
||||||
|
const msg = message.message.replace(/<[^>]*>?/gm, '')
|
||||||
|
if (msg.split(' ')[0] === 'play' && msg.split(' ').length === 2) {
|
||||||
|
if (msg.split(' ')[1].match(/^https?:\/\/www\.youtube\.com\/watch\?v=/i)) {
|
||||||
|
connection.playFile(ytdl(msg.split(' ')[1], { filter: 'audioonly' }), volume)
|
||||||
|
} else if (msg.split(' ')[1].match(/^https?:\/\//i)) {
|
||||||
|
connection.playFile(ytdlcore(msg.split(' ')[1], ['-x']), volume)
|
||||||
|
}
|
||||||
|
connection.sendTextMessage('Playing... ' + msg.split(' ')[1])
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})()
|
||||||
13
package.json
Archivo normal
13
package.json
Archivo normal
@@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"name": "grumble-youtube",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "Play audio in Grumble",
|
||||||
|
"main": "index.js",
|
||||||
|
"author": "ale",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"node-grumble": "latest",
|
||||||
|
"youtube-dl": "latest",
|
||||||
|
"ytdl-core": "latest"
|
||||||
|
}
|
||||||
|
}
|
||||||
Referencia en una nueva incidencia
Block a user