Skip to content

satorijs/satori

Folders and files

NameName
Last commit message
Last commit date

Latest commit

7b73eeb · Feb 28, 2025
Nov 25, 2024
Feb 25, 2025
Feb 28, 2025
Jun 25, 2022
Mar 25, 2023
Jan 23, 2025
Jan 7, 2025
Jun 25, 2022
Nov 25, 2024
Nov 18, 2022
May 15, 2024
Feb 28, 2025
Dec 23, 2024
May 15, 2024
Jan 2, 2025

Repository files navigation

Satori

The Universal Messenger Protocol

Roadmap

  • Infrastructure
    • @satorijs/core
    • @satorijs/element
    • @satorijs/satori
    • @satorijs/protocol
    • @satorijs/plugin-server
  • Ecosystem
    • DingTalk (钉钉)
    • Discord
    • KOOK (开黑啦)
    • Lark (飞书)
    • Line
    • Mail
    • Matrix
    • QQ Guild
    • Slack
    • Telegram
    • WhatsApp
    • WeCom (企业微信)
    • Wechat Official (微信公众号)
    • Zulip

Examples

Basic usage

import { Context } from '@satorijs/core'
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

import { Context } from '@satorijs/core'
import router from '@cordisjs/plugin-server'
import telegram from '@satorijs/adapter-telegram'

// 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',
})

// you need a router plugin to handle http requests
ctx.plugin(router)

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()