houko / satori

The Universal Messenger Protocol

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Satori

The Universal Messenger Protocol

Roadmap

  • Infrastructure
    • @satorijs/core
    • @satorijs/element
    • @satorijs/satori
    • @satorijs/database
    • @satorijs/server
  • Ecosystem
    • Discord
    • Telegram
    • OneBot (v11)
    • QQ Guild
    • KOOK (Kaiheila)
    • Feishu
    • Dingding
    • Wecom

Examples

Basic usage

import { Context } from '@satorijs/satori'
import discord from '@satorijs/adapter-discord'

// create a new context
const ctx = new Context()

// configure a Discord account
ctx.plugin(discord, {
  token: 'xxxxxx',
})

// listen to message events
ctx.on('message', (session) => {
  console.log(session.content)
})

// start application
await ctx.start()

Specifying protocol

// your application will be listening http://localhost:8080
// and be available at https://example.com
const ctx = new Context({
  port: 8080,
  selfUrl: 'https://example.com',
})

ctx.plugin(telegram, {
  // telegram supports two ways of connection: server and polling
  protocol: 'server',
  path: '/telegram',
  token: 'xxxxxx',
})

Multiple accounts

// specify multiple accounts with different platforms and protocols
ctx.plugin(discord, {
  token: 'xxxxxx',
})

ctx.plugin(telegram, {
  protocol: 'server',
  token: 'yyyyyy',
})

ctx.plugin(telegram, {
  protocol: 'polling',
  token: 'zzzzzz',
})

Removing an account

Based on cordis.

const fork = ctx.plugin(discord, {
  token: 'xxxxxx',
})

fork.dispose()

About

The Universal Messenger Protocol

License:MIT License


Languages

Language:TypeScript 100.0%