Giter VIP home page Giter VIP logo

spectrum-bot's Introduction

Spectrum bot Build Status Coverage

Is a crude NodeJs api to do stuff with Star Citizen's Spectrum (v0.3.5u)

Docs

You can find the Documentation in the Docs/ folder or at https://superd22.github.io/spectrum-bot/

Example

var bot = new Spectrum();

// Init the bot as user (you need to declare a config)
bot.initAsUser(config.username, config.password).then( (isConnected) => {
    let state = bot.getState();

    // Wait for internal state to be ready
    state.whenReady().then(() => {

        // Get a community
        let global = state.getCommunityByName("Star Citizen");
        // Get a lobby in that community
        let testLobby = global.getLobbyByName("general");

        // Get events from Lobby
        testLobby.subscribe();
        // Send a nice text
        testLobby.sendPlainTextMessage("Hello this is a test !");

        // Look for an user
        bot.LookForUserByName("UserNameOrHandle").then((users:SpectrumUser[]) => {
            let user = users[0];

            if(user)
            // Get a private Lobby with the user
            user.getPrivateLobbyWithUser().then((pmLobby) => {
                // subscribe to messages there
                pmLobby.subscribe();

                // Wait till we get a message from that user
                user.onMessage((message) => {
                    // Answer back !
                    pmLobby.sendPlainTextMessage("I got your text !");
                });
            });

        });
    });
    
});

How to use for your own bots

  1. npm install --save spectrum-bot to install the latest version of the api
  2. import { Spectrum } from "spectrum-bot" for typescript or const Spectrum = require("spectrum-bot"); for ES5
  3. Follow sample code to start building your own bot

How to dev

Dependencies : nodejs.

  1. Clone/download the repo
  2. run npm install to download/install dependencies.
    • depending on your setup, you might need to install globally ts-node & typescript npm install -g ts-node typescript
  3. create app/config.ts using the config.sample.ts template with the desired account
  4. (create an empty bot/cache/cookie.json)
  5. run ts-node app/bot.ts or its alias npm startto run the provided sample bot.

What's implemented

  • Send a text message to text lobby (emoji + mention support)
  • Send an embed (video/link/image) text message to lobby
  • Get Lobby
  • Get User
  • Get Community
  • Subscribe to a lobby to see whats happening there
  • declare custom callbacks for WS events

spectrum-bot's People

Contributors

jasonparrott avatar semantic-release-bot avatar superd22 avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

spectrum-bot's Issues

Support dropped ?

Hey!

I just wanted to know whether this project was dropped or not ? Seems interesting but can't seem to be able to login to RSI and stuff :(

thanks!

Error: Cannot find module './lib/'

I don't know if I'm just doing something wrong or something, but no matter what I do, I always get

Error: Cannot find module './lib/'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:580:15)
at Function.Module._load (internal/modules/cjs/loader.js:506:25)
at Module.require (internal/modules/cjs/loader.js:636:17)
at require (internal/modules/cjs/helpers.js:20:18)

I installed all the build tools needed, and it seems to build fine every time I install it, but anytime I try to do anything with it, it crashes. Tried with Node v8 and v10.

Again, maybe I'm just missing something obvious, dunno.

Thanks.

Warnings on compilation

../rxjs/observable/FromEventObservable.d.ts(11,103): error TS2304: Cannot find name 'NodeList'.
../rxjs/observable/FromEventObservable.d.ts(11,114): error TS2304: Cannot find name 'HTMLCollection'.
../rxjs/observable/dom/AjaxObservable.d.ts(16,23): error TS2304: Cannot find name 'XMLHttpRequest'.
../rxjs/observable/dom/AjaxObservable.d.ts(77,59): error TS2304: Cannot find name 'Event'.
../rxjs/observable/dom/AjaxObservable.d.ts(82,13): error TS2304: Cannot find name 'Event'.
../rxjs/observable/dom/AjaxObservable.d.ts(97,20): error TS2304: Cannot find name 'Event'.
../rxjs/observable/dom/AjaxObservable.d.ts(98,10): error TS2304: Cannot find name 'XMLHttpRequest'.
../rxjs/observable/dom/AjaxObservable.d.ts(108,32): error TS2304: Cannot find name 'Event'.
../rxjs/observable/dom/AjaxObservable.d.ts(108,44): error TS2304: Cannot find name 'XMLHttpRequest'.
../rxjs/observable/dom/AjaxObservable.d.ts(119,10): error TS2304: Cannot find name 'XMLHttpRequest'.
../rxjs/observable/dom/AjaxObservable.d.ts(124,39): error TS2304: Cannot find name 'XMLHttpRequest'.
../rxjs/observable/dom/AjaxObservable.d.ts(132,22): error TS2304: Cannot find name 'XMLHttpRequest'.
../rxjs/observable/dom/WebSocketSubject.d.ts(10,29): error TS2304: Cannot find name 'MessageEvent'.
../rxjs/observable/dom/WebSocketSubject.d.ts(11,33): error TS2304: Cannot find name 'Event'.
../rxjs/observable/dom/WebSocketSubject.d.ts(12,34): error TS2304: Cannot find name 'CloseEvent'.
../rxjs/observable/dom/WebSocketSubject.d.ts(15,63): error TS2304: Cannot find name 'WebSocket'.
../rxjs/observable/dom/WebSocketSubject.d.ts(27,13): error TS2304: Cannot find name 'WebSocket'.
../rxjs/observable/dom/WebSocketSubject.d.ts(28,32): error TS2304: Cannot find name 'Event'.
../rxjs/observable/dom/WebSocketSubject.d.ts(29,33): error TS2304: Cannot find name 'CloseEvent'.
../rxjs/observable/dom/WebSocketSubject.d.ts(32,63): error TS2304: Cannot find name 'WebSocket'.
../rxjs/observable/dom/WebSocketSubject.d.ts(36,23): error TS2304: Cannot find name 'MessageEvent'.
src/Spectrum/components/chat/textMessage.component.ts(129,56): error TS4052: Return type of public static method from exported class has or is using private name 'curEntities'.
src/Spectrum/components/chat/textMessage.component.ts(167,47): error TS4052: Return type of public static method from exported class has or is using private name 'curEntities'.
src/Spectrum/components/shared/user.component.ts(57,12): error TS4053: Return type of public method from exported class has or is using name 'SpectrumTextMessage' from external module "/tmp/test/node_modules/spectrum-bot/src/Spectrum/components/chat/textMessage.component" but cannot be named.
src/Spectrum/services/state.service.ts(242,12): error TS4053: Return type of public method from exported class has or is using name 'RSIApiResponse' from external module "/tmp/test/node_modules/spectrum-bot/src/RSI/interfaces/RSIApiResponse.interface" but cannot be named.

... Not very professional is it.

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.