Skip to content

gazf/deno-lineworks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

86 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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",
  },
});

Bot 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.