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

kbotify

v0.2.10

Published

kaiheila bot framework

Downloads

11

Readme

kBotify

基于 botRoot 的开黑啦 Bot 开发框架。

同时具有 sdk/botFramework 模式,可以按需使用。文档链接

npm version

如何开始?

你可以使用仓库模板:https://github.com/fi6/kBotify-template
参考其中的 src/commands/echo 文件夹即可。修改 src/configs 文件夹下 template-auth.ts 中的内容,并重命名为 auth.ts 即可开始使用。

优势

强大的交互功能,让你轻松完成各种需要大量交互的复杂功能。
完善的 API,稳定的迭代,让你专注开发,无需操心 SDK。
同时拥有 SDK 与命令框架模式,一行代码也能写 bot。

更新历史

0.2.3

  • 可以直接在 update message 中使用 card 了
  • 将_botInstance 重命名为 client,增加了 deprecate 标志
  • Card.toString()增加了选项,可以输出带有方括号或无方括号的 string。

0.2.1

  • 更新了少量 API,0.2.2 版本将会覆盖 99%API
  • 增加了class Card,废弃了之前使用 parser 的模式,提供更好的卡片消息操作性能。
  • 增加了GuildSession.awaitMessage,允许开发者等待用户在当前频道的下一条消息。
  • 增加了collecter,允许开发者在一定时间内收集频道内的消息,并且自定义停止的 trigger。
  • 解决了由于 pr#5 带来的 mention、reply 错误的问题

0.1.3

  • 替换 BaseData 为 BaseSession,简化了消息回复流程,增加对一次性文字 trigger 的支持。

TODO

  • [x] 文档
  • [x] 精简不必要的代码
  • [ ] 自动生成 Menu
  • [ ] 增加命令速率限制(全局,服务器,频道,角色,用户)
  • [ ] session 增加 context
  • [ ] 增加匹配模式:命令匹配/前缀匹配(如:直接匹配 .房间 创建,而不是先匹配.房间再匹配创建)
  • [ ] 增加 test
  • [ ] 插件化
  • [ ] aws lambda 接口

简单说明

请善用 ts 的自动补全。

Bot 用法

当前仅支持用"." "。"和@机器人 三种开头方式。未来考虑增加多种前缀,但是为了方便统一前缀,这里可能不会做修改,需要大家自行修改。 bot.processMsg=()=>{}

生成 Bot

const bot = new KBotify({
    mode: 'webhook',
    port: 12345,
    token: 'your kaiheila token',
    verifyToken: 'your kaiheila verify token',
    key: 'your kaiheila encrypt key',
    ignoreDecryptError: false, // 如果需要可以改为true
});

添加 Command

bot.addCommands(echoMenu, echoKmd);

添加 Alias

bot.addAlias(echoMenu, '复读', '重复');

启动 Bot

bot.connect();

SDK 使用方法

bot.message.on('text', (msg) => {});
bot.event.on('system', (event) => {});

Menu/App 使用方法

请查看 src/commands 下的示例。

import { MenuCommand } from 'commands/shared/menu';
import { BaseData } from 'commands/shared/types';
import { echoKmd } from './echo.kmd.app';

class EchoMenu extends MenuCommand {
    code = 'echo';
    trigger = 'echo';
    help = '目前只有`.echo kmd`一个指令。';
    intro = '复读菜单';
}

export const echoMenu = new EchoMenu(echoKmd);
echoMenu.addAlias(echoKmd, 'kmarkdown', '富文本');
import { AppCommand } from 'commands/shared/app';
import { AppFunc } from 'commands/shared/app.types';
import { BaseData } from 'commands/shared/types';

class EchoAll extends AppCommand {
    code = 'all';
    trigger = 'all';
    help = '`.echo all 时间`';
    intro = '在指定时间内复读全部文字';
    func: AppFunc<BaseSession> = async (session) => {
        session.setTextTrigger('', 6e4, (msg) => session.sendOnly(msg.content));
        return session.reply('将会复读下一次任意内容,1min有效', session);
    };
}

export const echoAll = new EchoAll();

卡片消息相关

官方提供的卡片消息编辑器:点击使用

完成编辑后,复制右侧自动生成的代码,然后把每张卡片使用const cardObject = new Card({...这里是卡片的内容})进行生成即可,发送的时候使用session.sendCard(cardObject)session.sendCardTemp(cardObject)进行发送。

你也可以直接复制自动生成的代码,使用session.sendCard([cardObjects])进行发送,具体可参考 src/commands 文件夹下的示例。


特别感谢:树根 本项目基于 BotRoot 开发 https://github.com/shugen002/BotRoot