This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

line.js

4.3.11 • Public • Published

Linejs

A wrapper for the line api in js.

if you have any questions feel free to msg me on Discord KingCosmic#2713 or line austyn-studdard

Installation

npm install --save line.js

Setup

  1. First of, to get real time events from line we have to make a http server

  2. If we want get that http server accesible to the real world instead of just localhost we will use ngrok

  3. To use ngrok you will have to open a cmd (Windows) or terminal (MacOS) and navigate to the folder where you have the

ngrok executable located and type ngrok http port replacing port with the port number you used in your config for line.js.

It will then give you a link that is something like https://8239483209.ngrok.io, copy that and head to your bots page

BotPage click on your bots Line Devlopers button and set its webhook to the ngrok link you got.

Usage

const line = require('line.js');

var client = new line.Client({
  channelAccessToken: "",
  channelSecret: "",
  port: "8080"
})

client.on("message", function(msg) {

  // msg = { content: String, author: Object, reply: function(content) }
  // msg.author = { username: String, id: Number, pictureUrl: Url, statusMessage: String, sendMessage: function(content) }
  // if its a group msg
  // msg.group = { id: Number, sendMessage: function(content), leave: function }

  if (msg.content == "ping") {
    msg.reply("pong");
  }

  if (msg.content == "msg me") {
    msg.author.sendMessage("Hello Sir");
  }

  if (msg.content == "leave" && msg.group) {
    msg.group.leave();
  }

})

Readme

Keywords

none

Package Sidebar

Install

npm i line.js

Weekly Downloads

9

Version

4.3.11

License

MIT

Unpacked Size

260 kB

Total Files

43

Last publish

Collaborators

  • kingcosmic