https://github.com/gazf/deno-lineworks
https://github.com/gazf/deno-lineworks
deno lineworks typescript
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/gazf/deno-lineworks
- Owner: gazf
- License: mit
- Created: 2024-05-27T08:59:27.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-12-16T06:54:29.000Z (over 1 year ago)
- Last Synced: 2024-12-16T07:39:41.505Z (over 1 year ago)
- Topics: deno, lineworks, typescript
- Language: TypeScript
- Homepage: https://jsr.io/@gazf/deno-lineworks
- Size: 114 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# deno-lineworks
[](https://github.com/gazf/deno-lineworks/actions)
[](https://github.com/gazf/deno-lineworks/blob/main/LICENSE)
[](https://jsr.io/@gazf/deno-lineworks)
[](https://github.com/gazf/deno-lineworks/pulse)
[](https://github.com/gazf/deno-lineworks/commits/main)
This package is for easy use of [LINE WORKS](https://line-works.com/).
## Basic usage
### Bot
```typescript
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)
```typescript
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.