Giter Site home page Giter Site logo

core's Introduction

poster

Bot Core ⚙️

Модуль в разработке. На данный момент работает только получение онлайна фракции.

Установка

$ npm i @nieopierzony/core --save
или
$ yarn add @nieopierzony/core

Пример

const { helpers, getFractionPlayers } = require('@nieopierzony/core');

const serverID = 8;
const fractionID = 1;

// Получение онлайна фракции на указанном выше сервере
(async () => {
  const players = await getFractionPlayers(serverID, fractionID);
  const onlinePlayers = players.filter(player => player.online);
  const seniors = players.filter(player => player.rank >= 9);

  console.log(
    'Онлайн фракции "%s" на сервере %s',
    helpers.fractionNames[fractionID - 1],
    helpers.serverNames[serverID - 1],
  );
  console.log(
    '\t- Всего во фракции: %d\n\t- Из которых онлайн: %d',
    players.length,
    onlinePlayers.length,
  );
  console.log(
    '\t- Руководство:\n',
    seniors.length === 0
      ? 'В руководстве никого не найдено'
      : seniors
          .sort((a, b) => b.rank - a.rank)
          .map(
            ({ nickname, rank, online }) =>
              `${nickname} - ${rank} ранг - ${online ? 'В сети' : 'Не в игре'}`,
          )
          .join('\n'),
  );
})();

API

core.getFractionPlayers(serverID, fractionID, requestConfig);

Обратите внимание: не делайте сразу много запросов на сайт, иначе ваш IP могут заблокировать

serverID

Тип: number

Порядковый номер сервера Arizona RP

fractionID

Тип: number

ID фракции, как указано на самом сервере

requestConfig

Тип: Object По умолчанию: {}

Конфигурация запроса Axios

Возвращает массив игроков во фракции:

// core.getFractionPlayers(1, 2);
/**
 * => [
 *    { id: '1', nickname: 'Vasya_Pupkin', rank: 1, online: true },
 *    { id: '2', nickname: 'John_Smith', rank: 10, online: false }
 *  ]
 */

Лицензия

MIT © Philipp Zelinski

core's People

Contributors

nautilus-philippus avatar

Stargazers

Dmitrii avatar Dmitrii avatar Zakharekt avatar  avatar  avatar

Watchers

 avatar

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.