Coder Social home page Coder Social logo

liamcottle / rustplus.js Goto Github PK

View Code? Open in Web Editor NEW
221.0 14.0 45.0 127 KB

Unofficial NodeJS library for controlling Smart Switches in the PC game Rust

JavaScript 95.07% HTML 4.93%
rust rustplus companion api websocket smart-switch smart-alarm team-chat rustplus-api rust-server

rustplus.js's People

Contributors

actown avatar alexemanuelol avatar dependabot[bot] avatar fizcko avatar icezman001 avatar infinity585 avatar liamcottle avatar nerif-tafu avatar olijeffers0n avatar raine avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rustplus.js's Issues

error

cant conect with rust+ app

getting websocket Parse Error: expected HTTP/ as a response after several successful requests

I get this error in NodeJS console when sending requests through the RustPlus.sendRequest method

Error: Parse Error: Expected HTTP/
    at Socket.socketOnData (_http_client.js:509:22)
    at Socket.emit (events.js:315:20)
    at addChunk (internal/streams/readable.js:309:12)
    at readableAddChunk (internal/streams/readable.js:284:9)
    at Socket.Readable.push (internal/streams/readable.js:223:10)
    at TCP.onStreamRead (internal/stream_base_commons.js:188:23) {
  bytesParsed: 0,
  code: 'HPE_INVALID_CONSTANT',
  reason: 'Expected HTTP/',
  rawPacket: <Buffer 88 02 03 e8>
}
Error: Parse Error: Expected HTTP/
    at Socket.socketOnData (_http_client.js:509:22)
    at Socket.emit (events.js:315:20)
    at addChunk (internal/streams/readable.js:309:12)
    at readableAddChunk (internal/streams/readable.js:284:9)
    at Socket.Readable.push (internal/streams/readable.js:223:10)
    at TCP.onStreamRead (internal/stream_base_commons.js:188:23) {
  bytesParsed: 0,
  code: 'HPE_INVALID_CONSTANT',
  reason: 'Expected HTTP/',
  rawPacket: <Buffer 88 02 03 e8>
}

But this does not happen on the first request, only after several requests have been successful already.
Is this some sort of throttling message from the rust game server that cannot be read as a HTTP response?

rustplus.config.json generation

How to run generation rustplus.config.json on ubuntu apache server ??
can modify code to not close after try run chrome launcher ??

Suggestion of fcm

npx @liamcottle/rustplus.js fcm-listen
npx @liamcottle/rustplus.js fcm-register

These two commands will no longer be available when trustplus.js is takedown.
How can we get player tokens, etc.?

Error-first callbacks

Hey. For instance the sendRequest method can't be promisified with the common tools because it's not returning the error first in the callback. Even if error wasn't possible due to the websocket architecture of listening to messages in the socket and picking the right callback based on seq, I think the first argument to the callback should be null.

Thoughts?

Unable to get Locked Crates and Explosions

Hi,

I'm trying to use the getMapMarkers call to see if there are any locked crates on the map and if Bradley has been taken. The issues is anytime I call this I'm only getting back Player Tokens, Vending Machines and CH47, even though I can see on the map in game Explosions and Crates. Have you got any idea why this would be happening.

Cheers

getCameraFrames will break nearby player's point of view

I noticed that players near enough to a CCTV that has been requested for a frame at least once will break those players' POVs. Reconnecting to the server (but still staying within the affected area of the CCTV) will temporarily fix it but will only last for a few seconds.

CCTV BUG

Do you have an idea on why this happens?

Code Examples For Smart Alarms?

Are there any code examples for how to process smart alarms?

running getInfo on the entityId of a smartAlarm doesn't return the message, And its not shown in the FCM notification either, Am I missing something?

TypeError: Cannot read properties of undefined (reading 'fromObject')

I'm making a private BOT now. The code is this
When I run it I get an error like this :

D:\ProjectFile\bot\node_modules\@liamcottle\rustplus.js\rustplus.js:138
        let request = this.AppRequest.fromObject({
                                      ^

TypeError: Cannot read properties of undefined (reading 'fromObject')
    at RustPlus.sendRequest (D:\ProjectFile\bot\node_modules\@liamcottle\rustplus.js\rustplus.js:138:39)
    at RustPlus.sendTeamMessage (D:\ProjectFile\bot\node_modules\@liamcottle\rustplus.js\rustplus.js:240:14)
    at print (file:///D:/ProjectFile/bot/tool/print.mjs:18:18)
    at RustPlus.<anonymous> (file:///D:/ProjectFile/bpt/index.mjs:102:5)
    at RustPlus.emit (node:events:394:28)
    at WebSocket.<anonymous> (D:\ProjectFile\bot\node_modules\@liamcottle\rustplus.js\rustplus.js:66:22)
    at WebSocket.emit (node:events:394:28)
    at WebSocket.setSocket (D:\ProjectFile\bot\node_modules\ws\lib\websocket.js:237:10)
    at ClientRequest.<anonymous> (D:\ProjectFile\bot\node_modules\ws\lib\websocket.js:974:15)
    at ClientRequest.emit (node:events:394:28)

Error: connect ETIMEDOUT

Error: connect ETIMEDOUT 192.248.164.111:28089
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1555:16) {
errno: -4039,
code: 'ETIMEDOUT',
syscall: 'connect',
address: '192.248.164.111',
port: 28089
}

everything worked fine for me, but after I made a mistake in the token, everything stopped working. now, even when changing authorization or specifying the correct token, I get this error all the time

Issue with getEntityInfo?

I'm testing getEntityInfo with an ID that someone gave me that they got from FCM, but I'm getting a response like this back:
getEntityInfo response message: {"response":{"seq":1,"error":{"error":"not_found"}}}

Here's the code I'm using:

instance.getEntityInfo(40402673, (message) => {
    console.log("getEntityInfo response message: " + JSON.stringify(message));
    return true;
});

Is there an event to get a list of already paired devices?

Hello, first I just want to say thank you for this code, I am in the process of porting it to c# :D
The one thing I am missing is finding a list of already paired device ids. it seems i have to have pair.js running while I pair them to get the ID. am i missing something?

New camera update released

Are there plans to add camera interaction, if possible? Right now, this feature is in the rust plus app.

Trackers removed

Will battlemetrics online trackers come back to the bot or will they be permanently unavailable?
If the latter, the channel probably shouldn't be created on initialization.

VS Code is launching instead of Google Chrome npx fcm-register

So when I use command-line tool fcm-register to pair server as described in docs Google Chrome should pop out. But instead it's Visual Studio Code with rustplus.js file. Logs:

D:\rustplus.js>npx @liamcottle/rustplus.js fcm-register

[main 2021-07-20T21:11:03.062Z] window: using vscode-file:// protocol and V8 cache options: bypassHeatCheck
[main 2021-07-20T21:11:03.152Z] update#setState idle

1
2

Couldn't find this issue so please tell me if it is duplicate. I also reinstalled Google Chrome, I don't want to touch VS Code for now as I use it constantly & have some settings I would like to keep. Thanks in advance!

Listeners stop responding after 2 hours

Me and a friend have been making separate bots using the library, but we've noticed it seems to disconnect after a couple of hours usually. There's no error message or crash, but it just stops picking up anything on the listeners until I restart the program or figure out a way to reconnect. I tried to implement a simple fix by listening for a disconnect but that didn't trigger either. Have you had any experience with this?
image
image
(More messages were sent after this but aren't picked up)

Camera Subscriptions

Issue when subscribing with a camera results in error code "ERR_UNHANDLED_REJECTION"

Copied code from the example for rendering, the code works when camera.subscribe line is removed.

RUST seems to have added new validation mechanisms

Certain servers can establish connections through APP, but using JS causes connection timeout exceptions. For example .CO EU MEDIUM(192.248.164.111:28085)
I'm not sure if it's because it uses some trick to hide the real address and port of the API
image
image
How can I solve this problem

how do i install this?

wondering how i install and use this i pasted the npm command into cmd and it downloaded but now im lost

Keep alive

There are a number of times when the socket seems to die, or just stop responding for me.
Could we implement some keepalive?

For example if they have ping / pong, or perhaps every minute to do a getServerInfo request (if no other request has been done).

Obviously i can do this myself, but would love it to be part of the framework.

Make register without opening new Browser

I'm trying to figure out a way to register a client through a web app and the problem there is that the pair.html has to be launched in the browser with the privacy thingy disabled and so doesn't work in the browser of the client. Would be nice if you find a way around this.

Are there more possibilities? What is the limit?

Great project! With the project of Nerif-tafu i've been implementing this in a React, mongoDB, node.js project that aims to copy the entire rust+ functionality and add so much more.

I was just wondering from your project, is everything included that you can get from the rustplus api?
Are there other things you can do? More info you can take?
How did you figure out all the data?

Anyway I can help with further expansion of the project or is everything that you can get from rustplus api already covered?

Listening to smart alarm notifications

Hello, and thank you for the great work on reverse engineering rust+ app!

Is there any information available how to listen for smart alarm notifications?

From what I understand based on the discussion in #13, those smart alarm notifications you see in iOS, for instance, would be available as FCM notifications.

However when I trigger a smart alarm in game, I only appear to get this generic server info message in the listen callback of pair.js. There's nothing about a smart alarm there, however, it does come at the same time when alarm is triggered so I wonder...

{
  img: 'https://files.facepunch.com/Alistair/02/05/0T35W1/server-header.png',
  port: '28083',
  ip: '51.77.57.19',
  name: '[RU] Facepunch 4',
  logo: 'https://files.facepunch.com/Alistair/02/05/1Z61F1/04_07-48-MagnificentLadybug.png',
  id: 'cdfeccce-7c2f-4d02-8a99-b94a183f3ada',
  url: 'http://www.playrust.com/',
  desc: "This is an official server owned and operated by Facepunch. \\n \\n People are free to speak whatever language they like. Don't be surprised if you get banned for being abusive."
}

How to list entities and/or get entity ids

First thanks for this work, it's pretty cool.

I'm wondering if you can provide some examples on how to get entity ids. I've paired and am able to do things like send a team message, but I want to react to smart alarms and I can't see how to find the entity id. Also, are the entities a poll mechanism as opposed to an event?

Parse Error: Expected HTTP/

Seems that some specific servers have issues w/ connecting, in this particular case this issue was on rusticated us main

Error: Parse Error: Expected HTTP/
    at Socket.socketOnData (node:_http_client:534:22)
    at Socket.emit (node:events:513:28)
    at addChunk (node:internal/streams/readable:324:12)
    at readableAddChunk (node:internal/streams/readable:297:9)
    at Readable.push (node:internal/streams/readable:234:10)
    at TCP.onStreamRead (node:internal/stream_base_commons:190:23)
Emitted 'error' event on RustPlus instance at:
    at WebSocket.<anonymous> (C:\Users\kamrote\Documents\GitHub\bot\node_modules\@liamcottle\rustplus.js\rustplus.js:71:22)
    at WebSocket.emit (node:events:513:28)
    at emitErrorAndClose (C:\Users\kamrote\Documents\GitHub\bot\node_modules\ws\lib\websocket.js:1002:13)
    at ClientRequest.<anonymous> (C:\Users\kamrote\Documents\GitHub\bot\node_modules\ws\lib\websocket.js:854:5)
    at ClientRequest.emit (node:events:513:28)
    at Socket.socketOnData (node:_http_client:543:9)
    at Socket.emit (node:events:513:28)
    [... lines matching original stack trace ...]
    at Readable.push (node:internal/streams/readable:234:10) {
  bytesParsed: 0,
  code: 'HPE_INVALID_CONSTANT',
  reason: 'Expected HTTP/',
  rawPacket: Buffer(4) [Uint8Array] [ 136, 2, 3, 232 ]
}

Smart Alarm is PATCHED??????

before, received a message when electricity was sent to your smart alarm. but recently it stopped working...
its bug? or patched?
(other pairing is received message) code

Rust_2023.05.28-01.00.mp4

Cannot read property 'fromObject' of undefined when running requests

Hey, i wanted to play around with this a little and made a new project in which i created a index.js and run the require command from the readme - it looks like this:

const RustPlus = require('rustplus-api');
var rustplus = new RustPlus('ip', port, '<steamid>', '<token>');

rustplus.on('message', (message) => {
    console.log("message received: " + JSON.stringify(message));
});

rustplus.getEntityInfo(1234567, (message) => {
    console.log("getEntityInfo response message: " + JSON.stringify(message));
    return true;
});

rustplus.sendTeamMessage('Hello World!', (message) => {
    console.log(message);
});

But whenever i call a function that would trigger a request i'm getting this error before it's even executed:

node index.js
H:\SourceCodes\Games\Rust\node-rustplus-test\node_modules\rustplus-api\rustplus.js:130
        let message = this.AppRequest.fromObject(payload);
                                      ^

TypeError: Cannot read property 'fromObject' of undefined
    at RustPlus.sendRequest (H:\SourceCodes\Games\Rust\node-rustplus-test\node_modules\rustplus-api\rustplus.js:130:39)
    at RustPlus.getEntityInfo (H:\SourceCodes\Games\Rust\node-rustplus-test\node_modules\rustplus-api\rustplus.js:193:14)
    at Object.<anonymous> (H:\SourceCodes\Games\Rust\node-rustplus-test\index.js:21:10)
    at Module._compile (internal/modules/cjs/loader.js:1200:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1220:10)
    at Module.load (internal/modules/cjs/loader.js:1049:32)
    at Function.Module._load (internal/modules/cjs/loader.js:937:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47

Do you know what i'm doing wrong?

How to use subscriptions?

I tried
rustplus.sendRequest({ checkSubscription: { entityID: "somerandomentityid" } }, (message) => { console.log(message); });

But this outputs
AppMessage { response: AppResponse { seq: 3, error: AppError { error: 'not_found' } } }
twice

See group chat message

Us there any way to see whenever a game chat message has been sent (and the content on that data)?

Thanks in advance, been using the npmjs package for a week and it's sooo good, great work!

Camera Frames

I saw you added some information about cctv frames and i wanted to check that out.

I have some trouble with getting it to work on my testserver, i enabled cctv rendering but the requests always return 0 bytes in GetCameraFrame.getJpgImage. The idenfiier it obv. the cctv name, but i'm not sure what i need to enter into the frame parameter, i tried 0, 90 (fov) and a few others but no success.

Maybe we could add some comments to request/response parameters in the protoc file for the generated code, as described here https://developers.google.com/protocol-buffers/docs/proto#adding_comments

And thanks again for finding all of this out, this is a awesome library.

getting ECONNRESET error

I'm having the same issue as this
Although it's already solved in latest release, my guess is rust companion still uses an older version of expo. It's not directly a bug with this project so feel free to close this issue.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.