npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mizuki-sdk

v1.0.0

Published

A plugin-in qq bot sdk

Downloads

65

Readme

mizuki-sdk

Document | 文档

mizuki-sdk

基于腾讯官方typescript sdk 的改版qb-sdk实现的 NTQQ 接入框架。

⚠️ 本项目由于使用了装饰器特性,只支持使用 typescript 进行开发。

安装与使用

注册QQ开放平台机器人

安装与配置本项目

在你的项目文件夹中

# npm
npm install mizuki-sdk

# yarn
yarn add mizuki-sdk

修改 tsconfig.json,开启装饰器

{
    "compilerOptions": {
        ...
        "experimentalDecorators": true,
        ...
    }
}

开始你的第一个 hello world

我们新建一个main.ts 和 一个文件夹 plugins,并在此文件夹新建一个index.ts,和hello-world.ts

// main.ts
import { server, AvailableIntentsEventsEnum } from 'mizuki-sdk'
import './plugins/index.ts'

const config = {
  appID: '<your appID>',
  token: '<your token>',
  intents: [AvailableIntentsEventsEnum.GROUP_AND_C2C_EVENT],
  sandbox: true,
}

await server.run(config)
// plugins/index.ts
export * from './hello-world'
// plugins/hello-world.ts
import { mapper, plugins, GroupContext, MessageType } from 'mizuki-sdk'

@plugins.register('hello-world')
export class HelloWorld {
  @mapper.onGroupAt()
  async helloWorld(groupContext: GroupContext) {
    await groupContext.post(groupContext.data.msg.group_openid, {
      msg_type: MessageType.TEXT,
      msg_id: groupContext.data.msg.id,
      content: 'hello world',
    })
  }
}

如果你想要自定义响应指令,可以通过onGroupAt中的options字段中的command设置,除此之外 ,你还可以通过priorityblock设置事件响应器优先级和是否阻塞

⚠️ 为了适配QQ官方的指令配置,默认响应指令头为\,也就是说,如果你设置command: 'hello',则需通过/hello触发

// plugins/hello.ts
import { mapper, plugins, GroupContext } from 'mizuki-sdk'

@plugins.register('hello')
export class Hello {
  @mapper.onGroupAt({ command: 'hello' })
  async hello(groupContext: GroupContext) {
    await groupContext.post(groupContext.data.msg.group_openid, {
      msg_type: MessageType.TEXT,
      msg_id: groupContext.data.msg.id,
      content: 'hello',
    })
  }
}

// ⚠️ 注意别忘了在plugin/index.ts中添加导出语句

如果你还想为server配置更多选项,目前提供了日志等级设置和启用内建插件功能,你可以将main.ts中对server的调用更改为:

// main.ts
await server
  .setLogLevel('info')
  .useBuiltinPlugins(['echo', 'get_message_data'])
  .run(config)