npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

nctalkclient

v1.6.0

Published

Client for nextcloud talk API

Downloads

67

Readme

Node.js Client for nextcloud talk API

To be used in an iobroker adapter

NPM version Downloads

NPM

Install

npm install nctalkclient

Changelog

1.6.0 (2023-02-23)

  • (Jochen Gerster) Added GetVersion function

1.5.0 (2023-02-23)

  • (Jochen Gerster) Added vhost support

1.4.0 (2021-01-07)

  • (Jochen Gerster) Added support for filesharing in messages

1.3.0 (2021-12-04)

  • (Jochen Gerster) Bugfix nextcloud talk http status code is evaluated to handle error cases with http request status OK, for example http status code 502

1.2.0 (2021-12-02)

  • (Jochen Gerster) Fixing eslint findings
  • (Jochen Gerster) Added debug logging to the nctalkconversation
  • (Jochen Gerster) Bugfix for spurious and wrong WaitMessage request Callback calls

1.1.0 (2021-11-22)

  • (Jochen Gerster) First release

Test / How to use

Idea is to create a smarthome / bot user in your nextcloud instance and administrate there the different rooms. All type of rooms will be shown in the listofrooms of the onReady event. Select the one to be used for the test. Make sure the room is "readOnly: 0". Adjust your server url, user, password and port.

const https = require("https");
const http = require("http");

const NextcloudTalk = require("nctalkclient");

// Use for test purposes - test server with self signed certs...
//process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = 0;


const Talk = new NextcloudTalk({
  server: private.talkcredentials.server,
  user: private.talkcredentials.user,
  pass: private.talkcredentials.pass,
  port: private.talkcredentials.port,
  debug: true
});


Talk.start(500);


// Talk client is ready and has fetched all required information / data to handle conversations
Talk.on("Ready", (listofrooms) => {

  // show all details about all rooms of the user
  console.log(listofrooms);

  let testroom_index = 2;
  console.log("Talk is ready make " + listofrooms[testroom_index].token + " active");
  Talk.RoomListenMode(listofrooms[testroom_index].token, true);
  Talk.SendMessage(listofrooms[testroom_index].token, "OnReady Test Nachricht");

    // Only receives Messages from the conversation with token
    Talk.on("Message_" + listofrooms[testroom_index].token, (msg) => {
      // msg is an array, usually with the length one, in the test we just take the first...
      if (msg[0].actorId.toLowerCase() == Talk.GetOwnActorIdLowerCase()) {
        console.log("OWN MESSAGEEVENT " + msg[0].message);
      }
      else {
        console.log("MESSAGEEVENT " + msg[0].message);
        if (msg[0].message == "time") {
          Talk.SendMessage(msg[0].token, new Date().toLocaleString());
        }
        if (msg[0].message == "test") {
          Talk.SendMessage(msg[0].token, "test reply");
        }
      }
    });

  Talk.ShareFile(listofrooms[2].token, "/talk/test123.jpg");


});

// Error
Talk.on("Error", (e) => {
  console.log("Error Event ", e);
});

// Debug
Talk.on("Debug", (e) => {
  console.log("Debug Event ", e);
});

listofrooms array example

Get Rooms
[
  {
    id: 11,
    token: '#####',
    type: 4,
    name: 'smartHome',
    displayName: 'Talk updates ✅',
    objectType: '',
    objectId: '',
    participantType: 3,
    participantFlags: 0,
    readOnly: 1,
    hasPassword: false,
    hasCall: false,
    canStartCall: true,
    lastActivity: 1613668924,
    lastReadMessage: 303,
    unreadMessages: 0,
    unreadMention: false,
    isFavorite: false,
    canLeaveConversation: true,
    canDeleteConversation: false,
    notificationLevel: 2,
    lobbyState: 0,
    lobbyTimer: 0,
    lastPing: 1636411357,
    sessionId: '0',
    guestList: '',
    lastMessage: {
      id: 303,
      token: '######',
      actorType: 'bots',
      actorId: 'changelog',
      actorDisplayName: 'Talk updates ✅',
      timestamp: 1613668924,
      message: '- You can now change your camera and microphone while being in a call',
      messageParameters: [],
      systemMessage: '',
      messageType: 'comment',
      isReplyable: false,
      referenceId: ''
    }
  },
  {
    id: 13,
    token: '####',
    type: 2,
    name: 'SmartHome',
    displayName: 'SmartHome',
    objectType: '',
    objectId: '',
    participantType: 1,
    participantFlags: 0,
    readOnly: 0,
    hasPassword: false,
    hasCall: false,
    canStartCall: true,
    lastActivity: 1636543411,
    lastReadMessage: 4949,
    unreadMessages: 0,
    unreadMention: false,
    isFavorite: false,
    canLeaveConversation: true,
    canDeleteConversation: true,
    notificationLevel: 2,
    lobbyState: 0,
    lobbyTimer: 0,
    lastPing: 1636489404,
    sessionId: '0',
    guestList: '',
    lastMessage: {
      id: 4949,
      token: '#####',
      actorType: 'users',
      actorId: 'smartHome',
      actorDisplayName: 'smartHome',
      timestamp: 1636543411,
      message: 'Klingel ist aus',
      messageParameters: [],
      systemMessage: '',
      messageType: 'comment',
      isReplyable: true,
      referenceId: ''
    }
  },
  {
    id: 12,
    token: '######',
    type: 1,
    name: 'name',
    displayName: 'name',
    objectType: '',
    objectId: '',
    participantType: 1,
    participantFlags: 0,
    readOnly: 0,
    hasPassword: false,
    hasCall: false,
    canStartCall: true,
    lastActivity: 355434,
    lastReadMessage: 33443,
    unreadMessages: 0,
    unreadMention: false,
    isFavorite: false,
    canLeaveConversation: true,
    canDeleteConversation: false,
    notificationLevel: 1,
    lobbyState: 0,
    lobbyTimer: 0,
    lastPing: 1636488989,
    sessionId: '0',
    guestList: '',
    lastMessage: {
      id: 5056,
      token: '#####',
      actorType: 'users',
      actorId: 'smartHome',
      actorDisplayName: 'smartHome',
      timestamp: 1636703054,
      message: 'Haustuer:(12708) [s] detected:car:99% person:98%  PIR\n' +
        'https://image',
      messageParameters: [],
      systemMessage: '',
      messageType: 'comment',
      isReplyable: true,
      referenceId: ''
    }
  }
]