Skip to main content

Built and signed on GitHub Actions

This package is for easy use of LINE WORKS.

This package works with Deno
This package works with Deno
JSR Score
100%
Published
2 weeks ago (0.0.10)

deno-lineworks

GitHub Actions Workflow Status GitHub JSR GitHub commit activity GitHub last commit

This package is for easy use of LINE WORKS.

Basic usage

Bot

import { Auth, Bot } from "jsr:@gazf/deno-lineworks";

const auth = new Auth({
  clientId: "YOUR_LINEWORKS_CLIENT_ID",
  clientSecret: "YOUR_LINEWORKS_CLIENT_SECRET",
  serviceAccount: "YOUR_LINEWORKS_SERVICE_ACCOUNT",
  privateKey: "YOUR_LINEWORKS_PRIVATE_KEY",
}, ["bot"]);

const bot = new Bot(
  "YOUR_BOT_ID",
  "YOUR_BOT_SECRET",
  auth,
);

// send messeage to user
await bot.send("users", "user_id", {
  content: {
    type: "text",
    text: "Bot send message",
  },
});

// send messeage to channel
await bot.send("channels", "channel_id", {
  content: {
    type: "text",
    text: "Bot send message",
  },
});

Echoback (Use Hono)

import { Auth, Bot } from "jsr:@gazf/deno-lineworks";
import { Hono } from "jsr:@hono/hono";

const auth = new Auth({
  clientId: "YOUR_LINEWORKS_CLIENT_ID",
  clientSecret: "YOUR_LINEWORKS_CLIENT_SECRET",
  serviceAccount: "YOUR_LINEWORKS_SERVICE_ACCOUNT",
  privateKey: "YOUR_LINEWORKS_PRIVATE_KEY",
}, ["bot"]);

const bot = new Bot(
  "YOUR_BOT_ID",
  "YOUR_BOT_SECRET",
  auth,
);

// Setup 'MessageCallback'
bot.on("message", (c) => {
  return c.reply({
    content: {
      type: "text",
      text: `echoback: ${c.e.content.text}`,
    },
  });
});

const app = new Hono();
app.mount("/path/to/callback", bot.fetch);

Deno.serve(app.fetch);

Authors

gazf https://github.com/gazf

License

Distributed under the MIT License.

Built and signed on
GitHub Actions
View transparency log

Add Package

deno add jsr:@gazf/deno-lineworks

Import symbol

import * as deno_lineworks from "@gazf/deno-lineworks";

---- OR ----

Import directly with a jsr specifier

import * as deno_lineworks from "jsr:@gazf/deno-lineworks";