Code Monkey home page Code Monkey logo

librus-api's Introduction

librus-api

npm License

Otwartoźródłowy klient HTTP parsujący odpowiedzi HTML serwera dziennika elektronicznego Librus / Synergia. Paczka nie jest oficjalnym produktem Synergia.

Instalacja

npm install librus-api

Usage

"use strict";
const Librus = require("librus-api");

let client = new Librus();
client.authorize("login", "pass").then(function () {
  // Send message to User 648158
  client.inbox.sendMessage(648158, "title", "body").then(
    () => {
      /** sucess */
    },
    () => {
      /** fail **/
    }
  );

  // Remove message with id 4534535
  client.inbox.removeMessage(4534535).then(
    () => {
      /** sucess */
    },
    () => {
      /** fail **/
    }
  );

  // List receivers
  client.inbox.listReceivers("nauczyciel").then((data) => {});

  // List announcements
  client.inbox.listAnnouncements().then((data) => {});

  // List all e-mails in folder(5) in page(2)
  client.inbox.listInbox(5).then((data) => {});

  // Get message with id 2133726 in folder 6
  client.inbox.getMessage(6, 2133726).then((data) => {});

  // Get attachments from message with id 181186 in folder 5
  client.inbox.getMessage(5, 181186).then((data) => {
    for (let f of data.files) {
      client.inbox
        .getFile(f.path)
        .then((response) => response.pipe(fs.createWriteStream(f.name)));
    }
  });

  // List all subjects
  client.homework.listSubjects().then((data) => {});

  // List subject homeworks, -1||undefined all
  client.homework.listHomework(24374).then((list) => {});

  // Download homework description
  client.homework.getHomework(257478).then((data) => {});

  // Get all absences
  client.absence.getAbsences().then((data) => {});

  // Get info about absence
  client.absence.getAbsence(5068489).then((data) => {});

  // Get timetable
  client.calendar.getTimetable().then((data) => {});

  // Get calendar
  client.calendar.getCalendar().then((data) => {});

  // Get event
  client.calendar.getEvent(4242342).then((data) => {});

  // Get grades
  client.info.getGrades().then((data) => {});

  // Get grade
  client.info.getGrade(23424234).then((data) => {});

  // Get scoring grade
  client.info.getPointGrade(234242234).then((data) => {});

  // Get name, surname and other account info
  client.info.getAccountInfo();

  // Get lucky number
  client.info.getLuckyNumber().then((data) => {});

  // Get notifications
  client.info.getNotifications().then((data) => {});
});

Licencja

The MIT License (MIT)

Copyright (c) 2023/2024 Mateusz Bagiński Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

librus-api's People

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

librus-api's Issues

Error in version 2.8.0

/home/norbi/Development/RadioBON/RadioBON-API/node_modules/librus-api/lib/tools.js:15
cheerio.prototype.trim = function() {
                       ^

TypeError: Cannot set properties of undefined (setting 'trim')
    at Object.<anonymous> (/home/norbi/Development/RadioBON/RadioBON-API/node_modules/librus-api/lib/tools.js:15:24)
    at Module._compile (node:internal/modules/cjs/loader:1120:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1174:10)
    at Module.load (node:internal/modules/cjs/loader:998:32)
    at Module._load (node:internal/modules/cjs/loader:839:12)
    at Module.require (node:internal/modules/cjs/loader:1022:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/home/norbi/Development/RadioBON/RadioBON-API/node_modules/librus-api/lib/resources/inbox.js:3:18)
    at Module._compile (node:internal/modules/cjs/loader:1120:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1174:10)
    at Module.load (node:internal/modules/cjs/loader:998:32)
    at Module._load (node:internal/modules/cjs/loader:839:12)
    at Module.require (node:internal/modules/cjs/loader:1022:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at /home/norbi/Development/RadioBON/RadioBON-API/node_modules/librus-api/lib/api.js:86:20
    at arrayEach (/home/norbi/Development/RadioBON/RadioBON-API/node_modules/lodash/lodash.js:530:11)
    at Function.forEach (/home/norbi/Development/RadioBON/RadioBON-API/node_modules/lodash/lodash.js:9410:14)
    at Librus._loadModules (/home/norbi/Development/RadioBON/RadioBON-API/node_modules/librus-api/lib/api.js:85:7)
    at new Librus (/home/norbi/Development/RadioBON/RadioBON-API/node_modules/librus-api/lib/api.js:32:10)
    at fetchLibrusData (/home/norbi/Development/RadioBON/RadioBON-API/utils.js:6:11)
    at Object.<anonymous> (/home/norbi/Development/RadioBON/RadioBON-API/utils.js:14:1)
    at Module._compile (node:internal/modules/cjs/loader:1120:14)

Node.js v18.6.0
[nodemon] app crashed - waiting for file changes before starting...

Node: v18.6.0

Oceny II Semestr

Możliwość pobierania ocen z II semestru, funkcja pobiera tylko I semestr

Content is undefined

Hi, today I wanted to read message content, but the API returning undefined
My code:

client.inbox.listInbox(5).then(data => {
        const latestMessage = data[0]
        client.inbox.getMessage(5, latestMessage.id).then(data => console.log(data));
        console.log(latestMessage.content)
}

Nie działa logowanie

Po zmianach tego lata - logowanie do Librusa przestało działać.

Poprawiłem w swoim forku:
mccartney@732d73f
(niezbyt elegancko, bo hardcode'ując URLe)

Ale może komuś się przyda...

Axios errror / zmiana headerów

Podczas próby połączenia z librusem, wyskakują same błedy na temat axiosa.

Aktualny kod

  const Librus = require("librus-api");
    let client = new Librus();
    client.authorize(name, password).then(() => {
        console.log("Logged in");
    }).catch((err: any) => {
        console.error(err);
    });

Błąd

(Login in daje siępoprzez kod, ale nie wiem czemu bo nie chce się zalogować defacto)
image

Errors instantly after executing file

Hi, i executed file (usage.js) with command node usege.js and those are the things which were shown to me.
How to check if i am really connected, logged in and i am in librus panel? How can i retrieve entire body from there?

/.../Librus-Frequency/librus_api/node_modules/axios/dist/node/axios.cjs:836
  AxiosError.call(axiosError, error.message, code, config, request, response);
             ^
AxiosError: connect ECONNREFUSED ::1:80
    at AxiosError.from (/.../Librus-Frequency/librus_api/node_modules/axios/dist/node/axios.cjs:836:14)
    at RedirectableRequest.handleRequestError (/.../Developer/Librus-Frequency/librus_api/node_modules/axios/dist/node/axios.cjs:3010:25)
    at RedirectableRequest.emit (node:events:513:28)
    at eventHandlers.<computed> (/.../Librus-Frequency/librus_api/node_modules/follow-redirects/index.js:14:24)
    at ClientRequest.emit (node:events:513:28)
    at req.emit (/.../Librus-Frequency/librus_api/node_modules/http-cookie-agent/dist/http/create_cookie_agent.js:84:16)
    at Socket.socketErrorListener (node:_http_client:494:9)
    at Socket.emit (node:events:513:28)
    at emitErrorNT (node:internal/streams/destroy:151:8)
    at emitErrorCloseNT (node:internal/streams/destroy:116:3)

Thank you very much for sharing this api <3

ERR_BAD_REQUEST on getting timetable

Hello,

I tried to use client.calendar.getTimetable() and got a 404 AxiosError.

Code:

"use strict";

const Librus = require('librus-api');
const client = new Librus();

client.authorize('<login>', '<password>').then(function () 
{
    client.calendar.getTimetable().then((data) => {console.log(data)});
});

Error:

C:\Users\jozek\Developer\librus\node_modules\axios\dist\node\axios.cjs:1913
    reject(new AxiosError(
           ^
AxiosError: Request failed with status code 404
...

The response also has this html content (part of it):

'  <h3>Błąd HTTP 404.0 — Not Found</h3> \n' +
'  <h4>Zasób, do którego chcesz uzyskać dostęp, został usunięty, jego nazwa uległa zmianie lub jest okresowo niedostępny.</h4> \n' +

I don't know if this is a Librus configuration issue by my school administrator or a librus-api bug...? Please let me know!

listInbox

Nie mam pojecia jak ma dzialac to api, probuje recznie robic requesty do librusa ale nie dostaje nic w odpowiedzi
natomiast tutaj listInbox(5) zwraca bardzo malo wiadomosci, da sie jakos zrobic zeby zwracal wszystkie?

nie ważne? zachowanie sie zmienia z czasem, raz zwraca niepelna liste raz pelna

listHomeworks

W readme, w przykładzie mamy client.homework.listHomeworks
tymczasem w API jest listHomework (bez s na końcu).

PS super kod pozdrawiam

Błąd w getNotifications()

Api z niewiadomych przyczyn nie jest w stanie odczytać poprawnie powiadomień. Mnie na librusie pokazuje, że mam 3 powiadomienia, a api pokazuje 1. Próbowałem to naprawić, lecz nie umiem.

Question

Is there any option for getting account name? For example I have account with login 138372972892782, but my name is DiaxManPl.

TypeScript

Przydały by się definicje typów do TypeScript. Jeśli jest potrzeba mogę sam zrobić i dać PR :)

Problem z Ocenami

Gdzie jest problem?

Przy poproszeniu o wszystkie oceny, zwracane jest "kurwa nic"

Wynik Programu


Kod

const Librus = require("librus-api");
require('dotenv').config()
const env = process.env

let client = new Librus();
client.authorize(process.env.LIBRUS_LOGIN, process.env.LIBRUS_PASSWD).then(function () {
    client.info.getGrades().then(data => console.log(data));
})

Dodatkowe Informacje

Potrzebuje szybko tych danych, żebym mógł ich używać w integracji 🥶
Szybka odpowiedz będzie mile widziana oraz doceniona ⭐

getMessage nie zwawiera `files`

getMessage() bezproblemowo podaje tytuł, treść czy inne pierdoły ale nie ma pola file które pozwalało by na pobranie plików

Node-Red

Cześć. Jest szansa zrobić z tego moduł do Node-Red?

Unhandled rejection StatusCodeError: 403

Cześć!
Co trzeba zrobić poza zainstalowaniem node.js i npm install librus-api? Potrzebne jest coś jeszcze?
By w konsoli uzyskać np. szczęśliwy numerek utworzyłem taki skrypt:
'use strict'; const Librus = require("librus-api"); let client = new Librus(); client.authorize("mojlogin", "haslo").then(function () { console.log(client.info.getLuckyNumber().then(data => {})); });

I wyświetla zamiast tej liczby masę tekstu:

Unhandled rejection StatusCodeError: 403 - "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"
...
</body>\r\n    </html>\r\n  "
    at new StatusCodeError (C:\Users\Tomek\node_modules\request-promise-core\lib\errors.js:32:15)
    at Request.plumbing.callback (C:\Users\Tomek\node_modules\request-promise-core\lib\plumbing.js:104:33)
    at Request.RP$callback [as _callback] (C:\Users\Tomek\node_modules\request-promise-core\lib\plumbing.js:46:31)
    at Request.self.callback (C:\Users\Tomek\node_modules\request\request.js:185:22)
    at Request.emit (events.js:400:28)
    at Request.<anonymous> (C:\Users\Tomek\node_modules\request\request.js:1154:10)
    at Request.emit (events.js:400:28)
    at Gunzip.<anonymous> (C:\Users\Tomek\node_modules\request\request.js:1076:12)
    at Object.onceWrapper (events.js:519:28)
    at Gunzip.emit (events.js:400:28)
    at endReadableNT (internal/streams/readable.js:1334:12)
    at processTicksAndRejections `(internal/process/task_queues.js:82:21)`

Te wyniki mają być jakoś przekierowane na stronę www z konsoli? Totalnie nie znam się na js ani na node.

listReceivers throws StatusCodeError: 500

Po invokowaniu
client.authorize('*******', '*******').then( client.inbox.listReceivers("nauczyciel").then(data => {console.log(data)}) )
otrzymuje
Unhandled rejection StatusCodeError: 500 - "" at new StatusCodeError (C:\Users\nate2463\Desktop\nwd-rel-zwln\node_modules\request-promise-core\lib\errors.js:32:15) at Request.plumbing.callback (C:\Users\nate2463\Desktop\nwd-rel-zwln\node_modules\request-promise-core\lib\plumbing.js:104:33) at Request.RP$callback [as _callback] (C:\Users\nate2463\Desktop\nwd-rel-zwln\node_modules\request-promise-core\lib\plumbing.js:46:31) at Request.self.callback (C:\Users\nate2463\Desktop\nwd-rel-zwln\node_modules\request\request.js:185:22) at Request.emit (events.js:210:5) at Request.EventEmitter.emit (domain.js:498:23) at Request.<anonymous> (C:\Users\nate2463\Desktop\nwd-rel-zwln\node_modules\request\request.js:1161:10) at Request.emit (events.js:210:5) at Request.EventEmitter.emit (domain.js:498:23) at IncomingMessage.<anonymous> (C:\Users\nate2463\Desktop\nwd-rel-zwln\node_modules\request\request.js:1083:12) at Object.onceWrapper (events.js:299:28) at IncomingMessage.emit (events.js:215:7) at IncomingMessage.EventEmitter.emit (domain.js:498:23) at endReadableNT (_stream_readable.js:1184:12) at processTicksAndRejections (internal/process/task_queues.js:80:21)
Wszystko inne działa

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.