wechaty-vorpal-contrib
TypeScript icon, indicating that this package has built-in type declarations

1.12.1 • Public • Published

wechaty-vorpal-contrib

Wechaty Vorpal Contrib NPM NPM Version

Wechaty Vorpal Chat CLI (Command Line Interface)

Wechaty Vorpal Contrib

Image: Tales of Zestiria

Requirements

  1. Node.js v16+
  2. NPM v7+
  3. Wechaty v0.40+
  4. WechatyVorpal v0.2+

Usage

You are welcome to send your Vorpal Extension to our contrib by creating a Pull Request!

# Extension Author Feature
1 Ding @huan Get a reply of dong
2 Eval @huan Run JavaSCript in your Wechaty bot right in the chat window!
3 Cash @huan Cross-platform Linux commands in pure ES6
4 MathMaster @huan Text game on WeChat: to become a math master!
5 Whoru @huan Make the bot do a introduction about itself
6 Version @huan Show the dependencies/devDependencies of the bot
import { Wechaty }        from 'wechaty'
import { WechatyVorpal }  from 'wechaty-vorpal'
import { Eval }           from 'wechaty-vorpal-contrib'

const vorpalExtensionList = [
  Eval(), // <- Put our vorpal contrib extensions at here.
]

const VorpalPlugin = WechatyVorpal({
  room: 'Your_Vorpal_CLI_Room_ID',
  use: vorpalExtensionList,
})

const wechaty = new Wechaty()
wechaty.use(VorpalPlugin)

Screenshot

UrlLink

Wechaty Vorpal UrlLink Extension

Eval

Wechaty Vorpal Eval Extension

Commands

Wechaty Vorpal Contrib

The Wechaty Vorpal Contrib includes the most useful commands from the Wechaty Contributors.

If you believe we should add more command to the contrib, please feel free to submit an proposal by creating an new issue, with your code in the PR!

1 Ding

import { Ding } from 'wechaty-vorpal-contrib'
vorpalExtensionList = [ Ding() ]

2 Eval

import { Eval } from 'wechaty-vorpal-contrib'
vorpalExtensionList = [ Eval() ]

Eval Example

To remove a member from a room, you can use the following eval code to achieve that:

eval
  const ROOM_TOPIC_RE=/Home 6/i;
  const MEMBER_NAME_RE=/纸超人/i;
  const room = await this.wechaty.Room.find({ topic: ROOM_TOPIC_RE });
  const memberList = await room.memberAll();
  const bob = memberList.filter(m => MEMBER_NAME_RE.test(m.name()))[0];
  await room.say("You have violated the code of conduct of our Wechaty Developers's Room, we need to move you out of this room.", bob);
  await this.wechaty.sleep(5000);
  await room.say('done');
  await room.del(bob);
  await this.log('done');

3 Cash

Cash is a cross-platform implementation of Unix shell commands written in straight ES6. No native compiling and no external dependencies.

import { Cash } from 'wechaty-vorpal-contrib'
vorpalExtensionList = [ Cash() ]
$ help

  Commands:

    alias [options] [name...]
    cat [options] [files...]
    cd [dir]
    clear
    cp [options] [args...]
    echo [options] [arg...]
     [options] [files...]
    export [options] [name...]
    false
    kill [options] [process...]
    ls [options] [paths...]
     [options] [directory...]
     [options] [args...]
    pwd [files...]
    sort [options] [files...]
    source [file] [params...]
    tail [options] [files...]
    touch [options] <files...>
    true
    grep [options] <pattern> [files...]  Grep (POSIX) implementation.
    rm [options] [files...]
     [options] [name...]

This extension is powered by Cash.

Learn more supported command at https://github.com/dthree/cash#supported-commands

4 MathMaster

Play game in WeChat and make you a master of math! (leader board support)

Wechaty Vorpal Math Master

import { MathMaster } from 'wechaty-vorpal-contrib'
vorpalExtensionList = [ MathMaster() ]

5 Whoru

Let the bot tell you about its version & server information.

import { Whoru } from 'wechaty-vorpal-contrib'
vorpalExtensionList = [ Whoru() ]

6 Version

Let the bot tell you its dependencies/devDependencies.

import { Version } from 'wechaty-vorpal-contrib'
vorpalExtensionList = [ Version() ]

Contributors

contributor contributor contributor contributor contributor contributor contributor contributor

History

main v1.0 (Oct 23, 2021)

Release v1.0 of Wechaty Vorpal Contrib.

  1. (Sep 20, 2021): Enable ESM Modules

v0.6 (July 10, 2020)

  1. Upgrade to wechaty-vorpal@0.6 to enhance the Command Action Functions
  2. MathMaster Extension for play game in WeChat!
  3. Add Whoru and Version extensions.

v0.2 (June 19, 2020)

Init the first version of Wechaty Vorpal Extensions for official Wechaty ChatOps Commands

  1. Ding Extension for trigger a dong reply
  2. Eval Extension for EVAL JavaScript code from the chat window!
  3. Cash Extension for Cross-platform Linux commands in pure ES6

Author

Huan LI (李卓桓), Tencent TVP of Chatbot, <zixia@zixia.net>

Profile of Huan LI (李卓桓) on StackOverflow

Copyright & License

  • Code & Docs © 2020 Huan LI (李卓桓) <zixia@zixia.net>
  • Code released under the Apache-2.0 License
  • Docs released under Creative Commons

Dependencies (6)

Dev Dependencies (12)

Package Sidebar

Install

npm i wechaty-vorpal-contrib

Weekly Downloads

5

Version

1.12.1

License

Apache-2.0

Unpacked Size

402 kB

Total Files

371

Last publish

Collaborators

  • zixia