Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/u9g/chatregex
Plugin for mineflayer to allow for matching a series of regex paterns.
https://github.com/u9g/chatregex
chat minecraft mineflayer regex
Last synced: about 2 months ago
JSON representation
Plugin for mineflayer to allow for matching a series of regex paterns.
- Host: GitHub
- URL: https://github.com/u9g/chatregex
- Owner: u9g
- License: mit
- Created: 2021-03-20T05:45:16.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2021-03-20T20:32:16.000Z (almost 4 years ago)
- Last Synced: 2024-11-20T07:51:59.735Z (about 2 months ago)
- Topics: chat, minecraft, mineflayer, regex
- Language: JavaScript
- Homepage:
- Size: 11.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ChatRegex
This package is a plugin for mineflayer to allow for matching a series of regex paterns.
# Installation:
`npm i chatregex`
## Example:
```js
const mineflayer = require('mineflayer')
const bot = mineflayer.createBot()
bot.loadPlugin(require('chatregex'))bot.on('spawn', () => {
bot.chatregex.addPatternSet('helloworld', [/<.+> Hello(.+)/, /<.+> World(.+)/], { repeat: true })
})bot.on('chat:helloworld', (matches) => {
console.log(matches)
})
```
In chat:
```
Hello1
World2
```
Output:
`[[' Hello1'], [' World2']]`
## API#### Functions
##### bot.chat.regex.addPatternSet(name, patterns, options?)
`name` - (string) name of the event emitted when the set is fully matched
`patterns` - (Array\) array of regex patterns to match before emitting matches
`options` - (object) optional
- repeat - (boolean) whether to emit this event multiple times, default is false
- parse - (boolean) whether to only emit the capture groups gotten from the matches, default is false#### Events
##### "chat:{name}" (matches) - emitted when all patterns are matched, this event is on the bot object
- matches - (Array\) array of matches