Skip to content

Commit

Permalink
feat: add some events and fix command,message
Browse files Browse the repository at this point in the history
  • Loading branch information
BIYUEHU committed Oct 28, 2023
1 parent a440959 commit a68b292
Show file tree
Hide file tree
Showing 32 changed files with 632 additions and 479 deletions.
77 changes: 32 additions & 45 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,94 +4,81 @@ All notable changes to this project will be documented in this file. See [standa

### [0.7.8](https://github.com/BIYUEHU/kotori-bot/compare/v0.7.7...v0.7.8) (2023-09-10)


### ✨ Features

* grouper plugin and favicon ([3640024](https://github.com/BIYUEHU/kotori-bot/commit/3640024d5a8b289826b2068a4a78b9397b9fdb5f))

- grouper plugin and favicon ([3640024](https://github.com/BIYUEHU/kotori-bot/commit/3640024d5a8b289826b2068a4a78b9397b9fdb5f))

### ✏️ Documentation

* change README.md ([68872c4](https://github.com/BIYUEHU/kotori-bot/commit/68872c4bfc95ed94d12db7474baf3bc45225f8d9))
* change README.md ([c2f3b76](https://github.com/BIYUEHU/kotori-bot/commit/c2f3b76b8391c66a624d3788baa46d0c53870358))
* change README.md ([fc84dc3](https://github.com/BIYUEHU/kotori-bot/commit/fc84dc3fe43160ac462603ddd284b2cb63e8029c))
* change README.md ([9095ea3](https://github.com/BIYUEHU/kotori-bot/commit/9095ea3177f18f63cb352d2ba752a73f135e3139))
* change README.md ([a68f312](https://github.com/BIYUEHU/kotori-bot/commit/a68f3126177cfc9da3c31fbad75df4df6d907f1b))
* change README.md ([233aa1a](https://github.com/BIYUEHU/kotori-bot/commit/233aa1a99aeda66a59f77618b78ea6af5905d075))

- change README.md ([68872c4](https://github.com/BIYUEHU/kotori-bot/commit/68872c4bfc95ed94d12db7474baf3bc45225f8d9))
- change README.md ([c2f3b76](https://github.com/BIYUEHU/kotori-bot/commit/c2f3b76b8391c66a624d3788baa46d0c53870358))
- change README.md ([fc84dc3](https://github.com/BIYUEHU/kotori-bot/commit/fc84dc3fe43160ac462603ddd284b2cb63e8029c))
- change README.md ([9095ea3](https://github.com/BIYUEHU/kotori-bot/commit/9095ea3177f18f63cb352d2ba752a73f135e3139))
- change README.md ([a68f312](https://github.com/BIYUEHU/kotori-bot/commit/a68f3126177cfc9da3c31fbad75df4df6d907f1b))
- change README.md ([233aa1a](https://github.com/BIYUEHU/kotori-bot/commit/233aa1a99aeda66a59f77618b78ea6af5905d075))

### 🚀 Chore

* some changence ([22e977e](https://github.com/BIYUEHU/kotori-bot/commit/22e977ee1da4b97a57698e74d8c27c0fbc125b5a))
* update lang format and changes ([a03f954](https://github.com/BIYUEHU/kotori-bot/commit/a03f95458d373260bcc8c870181d1b55bff48170))
* update lang format and changes ([774c7f1](https://github.com/BIYUEHU/kotori-bot/commit/774c7f1617890d0e754b369abe6c2565661f5510))
* update plugins and docs ([8dd8836](https://github.com/BIYUEHU/kotori-bot/commit/8dd883695ee761ba96324987f9ce597d63906bab))
- some changence ([22e977e](https://github.com/BIYUEHU/kotori-bot/commit/22e977ee1da4b97a57698e74d8c27c0fbc125b5a))
- update lang format and changes ([a03f954](https://github.com/BIYUEHU/kotori-bot/commit/a03f95458d373260bcc8c870181d1b55bff48170))
- update lang format and changes ([774c7f1](https://github.com/BIYUEHU/kotori-bot/commit/774c7f1617890d0e754b369abe6c2565661f5510))
- update plugins and docs ([8dd8836](https://github.com/BIYUEHU/kotori-bot/commit/8dd883695ee761ba96324987f9ce597d63906bab))

### [0.7.7](https://github.com/BIYUEHU/kotori-bot/compare/v0.7.6...v0.7.7) (2023-08-26)


### ✨ Features

* grouper plugin and favicon ([6756cee](https://github.com/BIYUEHU/kotori-bot/commit/6756cee88a5bf1e1b9e88a2becef1023ca401b3a))
- grouper plugin and favicon ([6756cee](https://github.com/BIYUEHU/kotori-bot/commit/6756cee88a5bf1e1b9e88a2becef1023ca401b3a))

### [0.7.6](https://github.com/BIYUEHU/kotori-bot/compare/v0.7.5...v0.7.6) (2023-08-25)


### ✨ Features

* **many plugins:** many plugins ([9e7464a](https://github.com/BIYUEHU/kotori-bot/commit/9e7464ad6c0bc3e10a673063d762eb469b8cf74c))
- **many plugins:** many plugins ([9e7464a](https://github.com/BIYUEHU/kotori-bot/commit/9e7464ad6c0bc3e10a673063d762eb469b8cf74c))

### [0.7.5](https://github.com/BIYUEHU/kotori-bot/compare/v0.7.4...v0.7.5) (2023-08-25)


### ✏️ Documentation

* update all plugins readme ([60afe34](https://github.com/BIYUEHU/kotori-bot/commit/60afe3488ac90d5b7a49dfcd702d27880ab2f0ff))

- update all plugins readme ([60afe34](https://github.com/BIYUEHU/kotori-bot/commit/60afe3488ac90d5b7a49dfcd702d27880ab2f0ff))

### ✨ Features

* create module,requester ([dba239d](https://github.com/BIYUEHU/kotori-bot/commit/dba239dbd4f1c4fe0067e4b603aab62c31049063))
* framework ([18cbe84](https://github.com/BIYUEHU/kotori-bot/commit/18cbe84ecb5cbbca91c009db5f2e2bd5db0a9351))
* manger and hitokotos plugin ([20ee234](https://github.com/BIYUEHU/kotori-bot/commit/20ee23496a209433c656032d300e5474da664945))
* plugins ([ea644e8](https://github.com/BIYUEHU/kotori-bot/commit/ea644e85641f39ddbe2fb0b3790cd401d2c758b8))
* querytool plugin ([d2e5d7c](https://github.com/BIYUEHU/kotori-bot/commit/d2e5d7c1465d58b84fb916d52c71985bd391f75f))

- create module,requester ([dba239d](https://github.com/BIYUEHU/kotori-bot/commit/dba239dbd4f1c4fe0067e4b603aab62c31049063))
- framework ([18cbe84](https://github.com/BIYUEHU/kotori-bot/commit/18cbe84ecb5cbbca91c009db5f2e2bd5db0a9351))
- manger and hitokotos plugin ([20ee234](https://github.com/BIYUEHU/kotori-bot/commit/20ee23496a209433c656032d300e5474da664945))
- plugins ([ea644e8](https://github.com/BIYUEHU/kotori-bot/commit/ea644e85641f39ddbe2fb0b3790cd401d2c758b8))
- querytool plugin ([d2e5d7c](https://github.com/BIYUEHU/kotori-bot/commit/d2e5d7c1465d58b84fb916d52c71985bd391f75f))

### 🐛 Bug Fixes

* regiser plugin events ([6dbca7e](https://github.com/BIYUEHU/kotori-bot/commit/6dbca7e436abc05842f51154af12a12d22e7c196))

- regiser plugin events ([6dbca7e](https://github.com/BIYUEHU/kotori-bot/commit/6dbca7e436abc05842f51154af12a12d22e7c196))

### 🚀 Chore

* clear git ([dec6941](https://github.com/BIYUEHU/kotori-bot/commit/dec6941a1346cecb8cc9556958d168219fab6e26))
* test ([28ace13](https://github.com/BIYUEHU/kotori-bot/commit/28ace134947815eeca6923df66bfe2bcb2a1117d))
* test ([bddffc8](https://github.com/BIYUEHU/kotori-bot/commit/bddffc8d05a222a47573baa5aec0bed7bb4a3acf))
* update config and .gitignore ([e723b93](https://github.com/BIYUEHU/kotori-bot/commit/e723b931b627ded62325a2a2ccc624532309ba2c))
* update gitignore ([1f8ee5e](https://github.com/BIYUEHU/kotori-bot/commit/1f8ee5e8f911cc52fa7b9a9c568b31faf4272b24))
- clear git ([dec6941](https://github.com/BIYUEHU/kotori-bot/commit/dec6941a1346cecb8cc9556958d168219fab6e26))
- test ([28ace13](https://github.com/BIYUEHU/kotori-bot/commit/28ace134947815eeca6923df66bfe2bcb2a1117d))
- test ([bddffc8](https://github.com/BIYUEHU/kotori-bot/commit/bddffc8d05a222a47573baa5aec0bed7bb4a3acf))
- update config and .gitignore ([e723b93](https://github.com/BIYUEHU/kotori-bot/commit/e723b931b627ded62325a2a2ccc624532309ba2c))
- update gitignore ([1f8ee5e](https://github.com/BIYUEHU/kotori-bot/commit/1f8ee5e8f911cc52fa7b9a9c568b31faf4272b24))

### 0.7.4 (2023-08-22)


### 💄 Styles

* **custom:** use eslint and prettier ([505334e](https://github.com/BIYUEHU/kotori-bot/commit/505334eb75705c142de7d3c51ea977000f5aa9d0))

- **custom:** use eslint and prettier ([505334e](https://github.com/BIYUEHU/kotori-bot/commit/505334eb75705c142de7d3c51ea977000f5aa9d0))

### ✅ Tests

* try a few ([ecb23a6](https://github.com/BIYUEHU/kotori-bot/commit/ecb23a65ac07c086a093f4632f54d0adf55e8bd9))

- try a few ([ecb23a6](https://github.com/BIYUEHU/kotori-bot/commit/ecb23a65ac07c086a093f4632f54d0adf55e8bd9))

### 🚀 Chore

* a few change ([303aaeb](https://github.com/BIYUEHU/kotori-bot/commit/303aaeb2e7830f351fc95ccf99c4733714a14b44))
* a few change ([2005749](https://github.com/BIYUEHU/kotori-bot/commit/2005749e491eceb22d7a69af3252a30430b81169))
* a few change ([fcf7069](https://github.com/BIYUEHU/kotori-bot/commit/fcf70698ef8f40a3063627e833f9565e835c6cd1))
* a few change ([ad582cb](https://github.com/BIYUEHU/kotori-bot/commit/ad582cb1424fda24085b4a7278df589acc0174dd))

- a few change ([303aaeb](https://github.com/BIYUEHU/kotori-bot/commit/303aaeb2e7830f351fc95ccf99c4733714a14b44))
- a few change ([2005749](https://github.com/BIYUEHU/kotori-bot/commit/2005749e491eceb22d7a69af3252a30430b81169))
- a few change ([fcf7069](https://github.com/BIYUEHU/kotori-bot/commit/fcf70698ef8f40a3063627e833f9565e835c6cd1))
- a few change ([ad582cb](https://github.com/BIYUEHU/kotori-bot/commit/ad582cb1424fda24085b4a7278df589acc0174dd))

### ♻️ Code Refactoring

* core plugin and i18n,locales ([d4d925e](https://github.com/BIYUEHU/kotori-bot/commit/d4d925e220c2cea01403a4339fe3dcfd2790a0e4))
- core plugin and i18n,locales ([d4d925e](https://github.com/BIYUEHU/kotori-bot/commit/d4d925e220c2cea01403a4339fe3dcfd2790a0e4))
8 changes: 5 additions & 3 deletions kotori.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
global:
command-prefix: '/'
lang: 'zh_CN'

adapter:
kotori:
extend: "qq"
master: 3324656453
lang: "zh_CN"
# 连接模式 可选: http ws ws-reverse 推荐首选ws-reverse
mode: ws-reverse
address: 'ws://127.0.0.1'
Expand All @@ -20,5 +23,4 @@ adapter:

cmd-test:
extend: "cmd"
master: 0720
lang: 'zh_CN'
master: 0720
2 changes: 1 addition & 1 deletion modules/adapter-cmd/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@kotori-bot/plugin-adapter-cmd",
"name": "kotori-plugin-adapter-cmd",
"version": "1.0.0",
"description": "Adapter For Cmd",
"main": "src/index.ts",
Expand Down
26 changes: 16 additions & 10 deletions modules/adapter-cmd/src/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
* @Blog: https://hotaru.icu
* @Date: 2023-09-29 14:31:09
* @LastEditors: Hotaru biyuehuya@gmail.com
* @LastEditTime: 2023-10-06 15:59:37
* @LastEditTime: 2023-10-28 21:14:31
*/
import { Adapter, AdapterConfig, Events, Msg, eventDataMsgSender, isObj } from '@kotori-bot/kotori';
import Kotori, { Adapter, AdapterConfig, Msg, eventDataMsgSender, isObj } from 'kotori-bot';
import CmdApi from './api';

interface Iconfig extends AdapterConfig {
Expand All @@ -23,9 +23,7 @@ function checkConfig(config: unknown): config is Iconfig {
}

export default class CmdAdapter extends Adapter<CmdApi> {
private messageId = 0;

public api: CmdApi = new CmdApi(this);
private messageId = 1;

public readonly platform: string = 'cmd';

Expand All @@ -38,17 +36,19 @@ export default class CmdAdapter extends Adapter<CmdApi> {
sex: 'male',
};
const newConfig = Object.assign(defaultConfig, config);
super(newConfig, identity);
super(newConfig, identity, CmdApi);
if (!checkConfig(newConfig)) throw new Error(`Bot '${identity}' config format error`);
this.config = newConfig;
process.stdin.on('data', data => this.handle(data));
}

public handle = (data: Buffer) => {
if (this.status.value !== 'online') return;
const message = data.toString();
let message = data.toString();
if (message === '\n' || message === '\r\n') return;
Adapter.emit({
message = message.replace('\r\n', '').replace('\n', '');

Kotori.emit({
type: 'private_msg',
messageId: this.messageId,
message,
Expand All @@ -73,8 +73,14 @@ export default class CmdAdapter extends Adapter<CmdApi> {
if (typeof (params as { message: string }).message !== 'string') return;
if ((params as { user_id: unknown }).user_id !== this.config.master) return;
process.stdout.write(`> ${(params as { message: string }).message} \r\n`);
this.messageId += 1;
Kotori.emit({
type: 'send',
api: this.api,
messageId: this.messageId,
});
};
Events.emit({
Kotori.emit({
type: 'connect',
adapter: this,
normal: true,
Expand All @@ -84,7 +90,7 @@ export default class CmdAdapter extends Adapter<CmdApi> {
};

public stop = () => {
Events.emit({
Kotori.emit({
type: 'disconnect',
adapter: this,
normal: true,
Expand Down
4 changes: 2 additions & 2 deletions modules/adapter-cmd/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
* @Blog: https://hotaru.icu
* @Date: 2023-09-29 14:31:13
* @LastEditors: Hotaru biyuehuya@gmail.com
* @LastEditTime: 2023-10-06 15:57:29
* @LastEditTime: 2023-10-28 17:51:02
*/
import { Api, Msg } from '@kotori-bot/kotori';
import { Api, Msg } from 'kotori-bot';

export default class CmdApi extends Api {
public send_private_msg = (message: Msg, userId: number) => {
Expand Down
6 changes: 5 additions & 1 deletion modules/adapter-qq/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
{
"name": "@kotori-bot/plugin-adapter-qq",
"name": "kotori-plugin-adapter-qq",
"version": "1.0.0",
"description": "Adapter For QQ",
"main": "src/index.ts",
"license": "GPL-3.0",
"author": "Hotaru <biyuehuya@gmail.com>",
"peerDependencies": {
"kotori-bot": "workspace:^"
},
"dependencies": {
"@types/ws": "^8.5.8",
"ws": "^8.14.2"
}
}

0 comments on commit a68b292

Please sign in to comment.