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

52bot

v0.0.23

Published

- 安装 & 初始化 ```shell # 1. 安装依赖框架 yarn add 52bot # or pnpm add 52bot # 2. 安装适配器(目前已支持qq官方机器人和icqq) yarn add @52bot/qq # 如果你需要使用 icqq , 可安装 @52bot/icqq # 2. 初始化配置文件 npx 52bot init -m dev ``` - 填写配置 打开生成在根目录的 `.dev.env` 文件,填入相关环境变量 ```text adapters = qq

Downloads

27

Readme

52bot

1. 快速上手

  • 安装 & 初始化
# 1. 安装依赖框架
yarn add 52bot # or pnpm add 52bot
# 2. 安装适配器(目前已支持qq官方机器人和icqq)
yarn add @52bot/qq # 如果你需要使用 icqq , 可安装 @52bot/icqq
# 2. 初始化配置文件
npx 52bot init -m dev
  • 填写配置 打开生成在根目录的 .dev.env 文件,填入相关环境变量
adapters = qq                             # 使用的适配器,多个适配器可用 “,” 分隔
builtPlugins = commandParser,hmr          # 启用的内置插件列表
pluginDirs = plugins                      # 需要加载哪个本地文件夹下的插件,多个文件夹可用 “,” 分隔
  • 目前已内置有 commandParserhmrechopluginManager 四个插件,其他插件请关注官方仓库和社区插件

  • 启动

  • 注意:首次启动会为你生成对应适配器的默认配置文件,需要您完成配置后再次启动

npx 52bot -m dev

插件开发

  • 新建文件testPlugin.js
const {Plugin} = require('52bot')

const testPlugin=new Plugin('test')

// ... 在这儿实现你的逻辑

module.exports=testPlugin

1.定义指令


// 在省略号出调用 testPlugin.command 可以定义一个指令
testPlugin
	.command('/百科 <keyword:string>')
	.action(async(_,keyword)=>{
		const {data}=await axios.get(`https://baike.deno.dev/item/${encodeURIComponent(keyword)}?encoding=text`)
		return data
	})

2. 定义中间件


// 在省略号出调用 testPlugin.middleware 可以往bot中注册一个中间件
testPlugin.middleware((message,next)=>{
	if(!message.raw_message.startsWith('hello')) return next()
    return message.reply('world')
})

3. 定义服务

  • 服务是一个虚拟概念,由插件开发者在插件中声明的特有属性,该属性可暴露给其他插件访问

// 在省略号出调用 testPlugin.service 可以定义一个服务
testPlugin.service('foo','bar')

console.log(testPlugin.foo) // 输出 bar
  • 注意:如果已有之前已加载同名的服务,将不可覆盖已有服务

  • 当插件被加载后,后续加载的插件即可访问到该服务

const {Plugin} = require('52bot')

const helloPlugin=new Plugin('hello')
console.log(helloPlugin.foo) // 输出bar

module.exports=testPlugin
  • 可选:定义服务类型
  • 开发者为服务添加类型声明后,其他人在使用服务时,将获得类型提示
declare module '52bot'{
    namespace Bot{
        interface Services{
            foo:string
        }
    }
}

使用插件

const {Bot} = require('52bot')
const bot = new Bot({
	// ...
})
bot.mount('[模块名]') // 按模块名称加载插件,将一次查找(./plugins>内置插件>官方插件库>社区插件库>node_modules)目录下对应名称的插件
bot.mount(plugin) // 直接加载对应插件实例
bot.loadFromDir('./plugins', './services') // 加载指定目录下的所有插件,可传入多个目录,将多次加载
bot.loadFromModule('@52bot/pluign-guild-manager') // 从模块加载插件,需要你自行安装对应插件包
bot.start()

卸载插件


bot.unmount('[插件名]') // 按插件名卸载对应的插件
bot.unmount(plugin) // 直接卸载对应插件实例
bot.start()