New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

bearychat

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bearychat

BearyChat API client for Node and the Browser.

0.1.0
Source
npm
Version published
Weekly downloads
35
3400%
Maintainers
1
Weekly downloads
 
Created
Source

bearychat.js

BearyChat API client for Node and the Browser.

Build Status Development Status

中文文档

Install

$ npm i bearychat

or with yarn

$ yarn add bearychat

Usage

incoming.send

import { incoming } from 'bearychat';

const myWebhookUri = 'https://hook.bearychat.com/incoming/keep-calm-and-pusing';

incoming
  .send(myWebhookUri, { text: 'Hello, world' })
  .then(() => {
    console.log('incoming sent!');
  });

incoming.builder

import { incoming } from 'bearychat';

incoming
  .withText('Hello, world')  // or .withMarkdown('**Hello, world**')
  .to('扯犊子')
  .withAttachment({ text: 'It is simple,' })
  .withAttachment({ text: 'but colorful', color: '#ffa500' })
  .build();

rtm.start

import { rtm } from 'bearychat';

const rtmToken = 'keep-secret-and-safe';

rtm.start(rtmToken)
  .then((user) => {
    console.log(user);
  });

rtm.currentTeamInfo

import { rtm } from 'bearychat';

const rtmToken = 'keep-secret-and-safe';

rtm.currentTeamInfo(rtmToken)
  .then((team) => {
    console.log(team);
  });

rtm.currentTeamMembers

import { rtm } from 'bearychat';

const rtmToken = 'keep-secret-and-safe';

rtm.currentTeamMembers(rtmToken)
  .then((members) => {
    console.log(members);
  });

rtm.currentTeamChannels

import { rtm } from 'bearychat';

const rtmToken = 'keep-secret-and-safe';

rtm.currentTeamChannels(rtmToken)
  .then((channels) => {
    console.log(channels);
  });

rtm.userInfo

import { rtm } from 'bearychat';

const rtmToken = 'keep-secret-and-safe';
const userId = '=bw4242';

rtm.userInfo(rtmToken, userId)
  .then((user) => {
    console.log(user);
  });

rtm.channelInfo

import { rtm } from 'bearychat';

const rtmToken = 'keep-secret-and-safe';
const channelId = '=bw4242';

rtm.channelInfo(rtmToken, channelId)
  .then((channel) => {
    console.log(channel);
  });

rtm.message

Provides handful helpers for rtm message parsing.

rtm.loop

To achive more flexible usage, bearychat.js won't provide any implementations for rtm.loop. You can use examples/rtm_loop as implementation reference.

Basically, rtm.loop contains 3 stages:

  • rtm.start: Use rtm token to authenticate user and open a websocket connection.
  • ping: Keep sending type=ping message to server after connected. Pinging interval with 5000ms is suggested.
  • loop: Subscribe to websocket's message event and consume the message comes from the server. You can use rtm.message for message parsing.

Test

$ npm run test

Contributing

LICENSE

MIT

Keywords

BearyChat

FAQs

Package last updated on 30 Dec 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts