3.0.0 • Published 1 year ago

multiplayerpianojs v3.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
1 year ago

Logo

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.

GitHub stars GitHub followers

3.0.0

1 year ago

2.0.3

2 years ago

2.0.2

2 years ago

2.0.5

2 years ago

2.0.4

2 years ago

2.0.7

2 years ago

2.0.6

2 years ago

2.0.9

2 years ago

2.0.8

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.5.4

2 years ago

1.5.3

2 years ago

1.5.2

2 years ago

1.5.1

2 years ago

1.5.0

2 years ago

1.4.1

4 years ago

1.4.0

4 years ago

1.3.8

4 years ago

1.3.7

4 years ago

1.3.6

4 years ago

1.3.5

4 years ago

1.3.4

4 years ago

1.3.3

4 years ago

1.3.2

4 years ago

1.3.1

4 years ago

1.3.0

4 years ago

1.2.0

4 years ago

1.1.9

4 years ago

1.1.8

4 years ago

1.1.7

4 years ago

1.1.6

4 years ago

1.2.4

4 years ago

1.2.3

4 years ago

1.2.2

4 years ago

1.2.1

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago