Use the Matrix adapter for Satori
main@satorijs/adapter-matrix package provides a Matrix adapter for the Satori framework, allowing you to integrate Satori with the Matrix communication protocol.repository·main·Indexed 42 days ago
https://github.com/satorijs/satoriA Universal Messenger Protocol providing a unified interface for interacting with various messaging platforms through a plugin-based adapter system. Satori supports adapters for Discord, Telegram, Slack, Lark (飞书), LINE, Matrix, and DingTalk, allowing developers to manage multiple accounts and event listeners across different communication protocols.
@satorijs/adapter-matrix package provides a Matrix adapter for the Satori framework, allowing you to integrate Satori with the Matrix communication protocol.@satorijs/adapter-line package provides a LINE adapter for the Satori framework. It allows you to integrate LINE messaging capabilities into your Satori-based applications. For detailed configuration and usage instructions, refer to the official documentation at https://koishi.chat/plugins/adapter/line.html.The @satorijs/adapter-lark package provides an adapter for the Lark (飞书) messaging platform, allowing Satori-based applications to communicate via Lark.
To use this adapter, you must install the package and integrate it into your Satori instance. Detailed configuration and platform-specific setup can be found in the official Lark adapter documentation.
Some adapters, such as Telegram, support different connection methods. You can specify the protocol (e.g., 'server' or 'polling') within the adapter configuration object. When using the 'server' protocol, you typically need to provide a path and ensure your Context is configured with a port and selfUrl to handle incoming HTTP requests (often using a router plugin).
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',
})To use Satori, create a new Context from @satorijs/core, register an adapter (e.g., Discord) using ctx.plugin(), define event listeners like ctx.on('message', ...), and then call await ctx.start() to run the application.
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()The Lark adapter provides extensive types for managing talent (candidate) information, including basic profiles, education, work experience, and customized data fields.
Key interfaces include:
Talent: The root object for a candidate, containing basic_info, education_list, career_list, etc.TalentBasicInfo: Core identity details like name, mobile, email, and nationality.TalentEducationInfo: Details regarding academic background, including degree, school, and field_of_study.TalentCareerInfo: Professional history including company, title, and start_time.TalentCustomizedDataObjectValue: A flexible structure for handling custom fields via object_id and children.export interface Talent {
/** 人才ID */
id?: string
/** 是否在猎头保护期 */
is_in_agency_period?: boolean
/** 是否已入职 */
is_onboarded?: boolean
/** 基础信息 */
basic_info?: TalentBasicInfo
/** 教育经历 */
education_list?: TalentEducationInfo[]
/** 工作经历 */
career_list?: TalentCareerInfo[]
/** 项目经历 */
project_list?: TalentProjectInfo[]
/** 作品 */
works_list?: TalentWorksInfo[]
/** 获奖 */
award_list?: TalentAwardInfo[]
/** 语言能力 */
language_list?: TalentLanguageInfo[]
/** 社交账号 */
sns_list?: TalentSnsInfo[]
/** 简历来源 */
resume_source_list?: TalentResumeSource[]
/** 面试登记表 */
interview_registration_list?: TalentInterviewRegistrationSimple[]
/** 简历附件id列表(按照简历创建时间降序) */
resume_attachment_id_list?: string[]
/** 最高学历 */
top_degree?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
/** 第一学历 */
first_degree?: 1 | 2 | 3 | 4 | 5 | 6 | 7
}The Lark adapter provides a comprehensive set of interfaces for managing employee profile data via ProfileSetting interfaces:
ProfileSettingPersonalInfo: The root interface for personal information, containing personal_basic_info, emergency_contacts, bank_accounts, nationals, dependents, hukou, and contact_addresses.ProfileSettingEmploymentInfo: Contains basic_info, probation_info, employment_record, and emp_contract_record.ProfileSettingCareer: Manages educations and work_experiences.ProfileSettingDataAttachment: Manages personal_records and custom_groups.The protocol communicates via Event objects. An Event contains metadata like sn (sequence number), timestamp, platform, and selfId, along with payload data specific to the event type (e.g., message, user, guild, member).
EventName defines the possible event types, which follow two patterns:
${Genres}-${Actions} where Genres are friend, channel, guild, guild-member, guild-role, guild-file, or guild-emoji, and Actions are added, deleted, or updated.message, message-deleted, message-updated, message-pinned, message-unpinned, interaction/command, reaction-added, reaction-deleted, reaction-deleted/one, reaction-deleted/all, reaction-deleted/emoji, send, friend-request, guild-request, or guild-member-request.An Event payload can be treated as a MessageLike (either a Message or an Event).
@satorijs/core Session object is augmented with a line property. This property contains the WebhookEvent and Internal data specific to the LINE platform, allowing you to access event-specific metadata during message handling.When using the @satorijs/adapter-discord adapter, you can construct interactive messages using various component types. Components must be wrapped in an ActionRow to be sent in a message.
Supported component types include:
Button: Clickable buttons.SelectMenu: Menus for selecting options (including User, Role, Mentionable, and Channel selects).TextInput: Text input fields for users to fill out.ActionRow: A container that holds a collection of components.import { ActionRow, Button, ButtonStyles, ComponentType } from '@satorijs/adapter-discord';
const row: ActionRow = {
type: ComponentType.ACTION_ROW,
components: [
{
type: ComponentType.BUTTON,
style: ButtonStyles.PRIMARY,
label: 'Click Me',
custom_id: 'my_button_id'
}
]
};The Discord adapter uses several interfaces to represent invite data:
InviteThe base object representing a Discord invite.
code: The unique invite code.channel: A partial Channel object.guild: A partial Guild object.inviter: The User who created the invite.target_type: Invite.TargetType (1: STREAM, 2: EMBEDDED_APPLICATION).Invite.MetadataAn extension of Invite containing usage statistics.
uses: Number of times used.max_uses: Maximum allowed uses.max_age: Duration in seconds before expiry.temporary: Whether the invite grants temporary membership.created_at: Creation timestamp.Invite.StageInstanceData for Stage channels.
members: List of GuildMember objects currently speaking.participant_count: Total users in the Stage.speaker_count: Users currently speaking.topic: The Stage topic string.304023 code). To handle this, ensure your bot has the MESSAGE_AUDIT intent enabled. The adapter provides an audit mechanism that listens for qq/message-audit-pass and qq/message-audit-reject events to resolve the message status.