multiplayerpianojs
v3.0.0
Published
An easy to use NodeJS library for Multiplayerpiano.com & mppclone.com otherwise known as MPP to create chat bots.
Downloads
13
Maintainers
Readme
Foreword
Wrote this to help developers create bots for https://multiplayerpiano.com/ / https://mppclone.com/ simple and more streamlined. The current method of all devs manually interacting with the websocket seemed a bit inefficient and non-beginner friendly. Enter MultiplayerPianoJS!
Installation
Written on NodeJS v17.5
npm install multiplayerpianojs
YOU MUST GET A TOKEN FROM MPPCLONE.COM OWNER!
To get one, join the discord https://discord.gg/338D2xMufC . Using this without a token will result in a 24 hour ban so be careful!
Example Usage
Bigger example seen here
Full bot framework seen here
const MPPClient = require('multiplayerpianojs')
const mpp = new MPPClient('Your Token')
// const mpp = new MPPClient(token, SCOCKS/HTTPS PROXY HERE) alternatively
mpp.connect()
// On connect
mpp.on('connected', () => {
console.log('bot connected')
mpp.setChannel('test3')
})
mpp.on('userLeave', user => {
console.log(`User left: ${user.name}`)
})
mpp.on('userJoin', user => {
console.log(`User joined: ${user.name}`)
})
// Example chat message event
mpp.on('message', msg => {
const args = msg.content.split(' ')
if (args[0] === '!setname') {
mpp.setUser(args[1])
}
if (args[0] === '!joinroom') {
mpp.setChannel(args[1])
}
})
Methods/Functions
- connect()
Connects bot to the WS
- disconnect()
Disconnects bot to the WS
- setChannel(String name)
Sets the current channel
- setName(String name, String hexColor)
Sets the current name & tag color
- moveMouse(Int x, Int y)
Moves client mouse cursor
- dm(String msg, String id)
Sends a dm to a specific user
- giveCrown(String id)
If bot has crown (owner of room), give to user id
- changeChannelSettings(Object settings)
Change the room settings if owner
// Example Object of settings
{
color: '#0066ff',
color2: '#ff9900',
chat: 'false'
}
- ban(String id, Int ms)
Bans a user from channel for set time, requires owner/crown
- unBan(String id)
un-Bans a user from channel, requires owner/crown
- sendMessage(String msg)
Sends a message in chat
- sendNotes(Array notes, Int time)
Sends notes to be played at specific time, defaults to current time
// Example array of notes
[
{
"n":"c3", //note
"v":0.75 //velocity
},
{
"n":"c3",
"d":100, //delay from message to trigger note ms
"s":1 //if the note is a note stop
}
]
Events
- connected
Fired on bot connection to websocket
- message(Object)
Fired when chat message recieved
- dm(Object)
Fired when direct message is recieved
- userJoin(Object)
Fired when user joins the channel
- userLeave(Object)
Fired when user leaves the channel
- notes(Object)
Fired when user sends notes
Properties
- proxy
Currently used proxy
- hasCrown
If the bot has the crown (room ownership)
- user
Current user object
- room
Current room object
- allRooms
All current existing rooms
- token
Current token
Dependencies
- https-proxy-agent
- socks-proxy-agent
- ws
Planned Features
You can see the planned features here
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
All code must follow standardjs principles & Gitflow branching strategy. Keep documentation thorough as well.