@broid/api-sdk
Broid's API SDK javascript module with Typescript support. Check out the [docs](./docs/classes/_index_.broidapisdk.md) for parameters and usage.
Last updated 3 years ago by killix .
AGPL-3.0+ · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @broid/api-sdk 
SYNC missed versions from official npm registry.

Broid API Javascript/Typescript SDK

Broid's API SDK javascript module with Typescript support. Check out the docs for parameters and usage.

const broidSDK = require("@broid/api-sdk");

const botActorID = "";
const auto_reply = true;

const sdk = new broidSDK({
  secretID: '',
  secret: '',
});

const socket = sdk.realtime()
  .then((socket) => socket.subscribe({
		next: (data) => {
      if (!data['@context']) {
        console.log('system: ', data);
        return;
      }

      console.log('user: ', data);
      const actorID = data.actor.id || "";
      if (actorID === botActorID) { return; }

      const dataType = data.type.toLowerCase() || null;
      console.log('sending,,,', dataType);

      if (dataType === 'create' || dataType === 'update' || dataType === 'delete') {
        if (auto_reply) {
          let reply = data;
          reply.to = reply.actor;
          reply.object.content = `ping - ${reply.object.content}`;

          sdk.sendMessage(reply)
            .then(() => console.log('me: ', reply))
            .catch((err) => console.error(err.message));
        }
      }

    },
		error: (err) => console.error(`Something went wrong: ${err.message}`),
	}));

Current Tags

  • 0.0.3                                ...           latest (3 years ago)

3 Versions

  • 0.0.3                                ...           3 years ago
  • 0.0.2                                ...           3 years ago
  • 0.0.1                                ...           3 years ago
Downloads
Today 0
This Week 0
This Month 3
Last Day 0
Last Week 3
Last Month 1
Dependencies (8)
Dev Dependencies (14)
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |