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

@eine-nineteen/eine

v0.0.34

Published

[WIP] Eine Framework

Downloads

47

Readme

🎩 Eine

API Document

(WIP) Another TypeScript framework to build a QQ bot.

npm install @eine-nineteen/eine --save-dev

Simple Usage

import Eine, { Components, Filters, Types } from "@eine-nineteen/eine";

const { Plain, ImageFrom } = Components;
const { SentBy, TextEquals } = Filters;
const { EventHandleResult } = Types;

// new Eine(config: Parital<EineOptions>)
const eine = new Eine({
  verifyKey: "YourVerifyKey",
  adapters: {
    http: {
      host: "127.0.0.1",
      port: 8080,
    },
    ws: {
      host: "127.0.0.1",
      port: 8080,
    },
  },
  qq: 12345678,

  // Eine depends on MongoDB to record something.
  // If you don't need, disable the follwing options:
  // enableDatabase: false,
  // enableServer: false,
  mongoConfig: {
    username: 'admin',
    password: 'admin',
    dbName: 'BOT',
  },

  // [experiment] concurrency mode
  // start many eine processes to handle events and messages
  // use with caution!
  enableConcurrent: true,
});

// start Eine
eine.init()
  .then(eine.verify)
  .then(eine.bind)
  .then(async () => {
    const profile = await eine.http!.botProfile();
    console.log("MyProfile: ", profile);
  });

// Register an event listener:
// eine.on(eventType: EineEventType)(handler: EventCallback)
eine.on('FriendMessage', 'GroupMessage')(async ({
  messageChain,
  quote,
  recall,
  reply,
  sender,
  str,
}: Partial<Types.EventCallbackParams>) => {
  // Do something with messageChain, sender, str(serialized messageChain)...
  // and use reply(messageChain), recall(messageChain), recall() to react...

  if (str.contains("hello!")) {
    reply!([
      Plain("Hi!"), 
      ImageFrom("./hello.jpg") 
    ]);
    return EventHandleResult.DONE;          // return DONE to block other events
  }

  return EventHandleResult.CONTINUE;        // ...or CONTINUE to react next event
})

// with Eine's wait mechanism, you can easily write an interactive procedure:
const MASTER = 10001;
eine.on('FriendMessage', SentBy(MASTER), TextEquals("/shutdown"))(function*() {
  const { iterator, sender, reply, wait }: Types.EventInterruptParams = yield null;
  reply!(["send /confirm to shutdown BOT."]);

  // wait(iterator: EventIterator, filters: EventFilter)
  const { messageChain } = yield wait(iterator, TextEquals("/confirm"));    
  reply!(["BOT is shutting down."]);
  eine.shutdown(0);
  
  return EventHandleResult.DONE;      // this should never reached
                                      // but you should return it 
                                      // when using wait() to do othewr things.
});

Advanced

  • Eine provided an simple GUI admin panel. You can visit http://[hostname]:9119 to use the panel.
  • Eine provided an asynchronized encapsulation of node-canvas called EinePainter. Check eine.painter for more detail.
  • Eine provided a logging system eine.logger. You can use logLevel option to control the level of logs.

License

Copyright(c) 2021 @kirainmoe

MIT License