Skip to content

RshengYoung/push-integration

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

80 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🔸Push Integration

Install

Using npm

$ npm install --save push-integration

Supports

Platform
Line
Messenger
Wechat

Example

With JavaScript

const bot = require("push-integration")

const lineClient = new bot.LineClient({
    id: "<Channel id>",
    secret: "<Channel secret>",
    token: "<Channel access token>"
}, "<Channel name>")
const clients = new bot.Client([lineClient])

With TypeScript

import * as bot from "push-integration"
const lineClient = new bot.LineClient({
    id: "<Channel id>",
    secret: "<Channel secret>",
    token: "<Channel access token>"
}, "<Channel name>")
const clients = new bot.Client([lineClient])

or

import { Client, LineClient, WechatClient } from "push-integration"
const lineClient = new Client({
    id: "<Channel id>",
    secret: "<Channel secret>",
    token: "<Channel access token>"
}, "<Channel name>")
const clients = new Client([lineClient])

Add new Channel

const wechatClient = new WechatClient(CONFIG, "<Channel name>")
clients.use(wechatClient)

Send Message

const message = {
    channel: "<Channel name>",
    receiver: "<User id>",
    message: {
        type: "<Message type>",
        ...<Message object>
    }
}

clients.send(message)
    .then(result => {
        console.log(JSON.stringify(result, null, 4))
        /*
        {
            status: "ok"
        }
        */
    })
    .catch(error => {
        console.log(JSON.stringify(error, null, 4))
        /*
        {
            status: "error",
            message: "<Error message>"
        }
        */
    })

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published