Commit 7a10f28b authored by 神楽坂玲奈's avatar 神楽坂玲奈

es

parent a27d3224
Pipeline #8116 passed with stages
in 4 minutes and 10 seconds
......@@ -9,10 +9,12 @@
"version": "0.0.1",
"license": "UNLICENSED",
"dependencies": {
"@elastic/elasticsearch": "^7.16.0",
"@koishijs/plugin-assets-s3": "^1.0.0-beta.4",
"@nestjs/common": "^8.0.0",
"@nestjs/config": "^1.1.5",
"@nestjs/core": "^8.0.0",
"@nestjs/elasticsearch": "^8.0.0",
"@nestjs/platform-express": "^8.0.0",
"@nestjs/platform-ws": "^8.2.4",
"@nestjs/swagger": "^5.1.5",
......@@ -1904,6 +1906,25 @@
"node": ">=12"
}
},
"node_modules/@elastic/elasticsearch": {
"version": "7.16.0",
"resolved": "https://registry.npmjs.org/@elastic/elasticsearch/-/elasticsearch-7.16.0.tgz",
"integrity": "sha512-lMY2MFZZFG3om7QNHninxZZOXYx3NdIUwEISZxqaI9dXPoL3DNhU31keqjvx1gN6T74lGXAzrRNP4ag8CJ/VXw==",
"dependencies": {
"debug": "^4.3.1",
"hpagent": "^0.1.1",
"ms": "^2.1.3",
"secure-json-parse": "^2.4.0"
},
"engines": {
"node": ">=12"
}
},
"node_modules/@elastic/elasticsearch/node_modules/ms": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="
},
"node_modules/@eslint/eslintrc": {
"version": "0.4.3",
"resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-0.4.3.tgz",
......@@ -2629,6 +2650,16 @@
}
}
},
"node_modules/@nestjs/elasticsearch": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/@nestjs/elasticsearch/-/elasticsearch-8.0.0.tgz",
"integrity": "sha512-Yr0DldZA2pZGAF77R7CDClbXJd6cKctI5zgFc/6vFARjaHhRwETyeTES/nRiQLCZ+hfWmpRyvu1YX3reNMqW6A==",
"peerDependencies": {
"@elastic/elasticsearch": "^7.4.0",
"@nestjs/common": "^6.0.0 || ^7.0.0 || ^8.0.0",
"rxjs": "^6.2.1 || ^7.2.0"
}
},
"node_modules/@nestjs/mapped-types": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/@nestjs/mapped-types/-/mapped-types-1.0.0.tgz",
......@@ -6954,6 +6985,11 @@
"safe-buffer": "~5.2.0"
}
},
"node_modules/hpagent": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/hpagent/-/hpagent-0.1.2.tgz",
"integrity": "sha512-ePqFXHtSQWAFXYmj+JtOTHr84iNrII4/QRlAAPPE+zqnKy4xJo7Ie1Y4kC7AdB+LxLxSTTzBMASsEcy0q8YyvQ=="
},
"node_modules/html-encoding-sniffer": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-2.0.1.tgz",
......@@ -10301,6 +10337,11 @@
"resolved": "https://registry.npmjs.org/schemastery/-/schemastery-2.1.2.tgz",
"integrity": "sha512-iHwWfKxWaTFgZmKNULNtgyo8VDpdEWx31b6+j0tGTST8dBIYU7VYAHmq5qdYKYZ0uNSM5u57c09cuN75Yf7WwQ=="
},
"node_modules/secure-json-parse": {
"version": "2.4.0",
"resolved": "https://registry.npmjs.org/secure-json-parse/-/secure-json-parse-2.4.0.tgz",
"integrity": "sha512-Q5Z/97nbON5t/L/sH6mY2EacfjVGwrCcSi5D3btRO2GZ8pf1K1UN7Z9H5J57hjVU2Qzxr1xO+FmBhOvEkzCMmg=="
},
"node_modules/semver": {
"version": "7.3.5",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz",
......@@ -13659,6 +13700,24 @@
"@cspotcode/source-map-consumer": "0.8.0"
}
},
"@elastic/elasticsearch": {
"version": "7.16.0",
"resolved": "https://registry.npmjs.org/@elastic/elasticsearch/-/elasticsearch-7.16.0.tgz",
"integrity": "sha512-lMY2MFZZFG3om7QNHninxZZOXYx3NdIUwEISZxqaI9dXPoL3DNhU31keqjvx1gN6T74lGXAzrRNP4ag8CJ/VXw==",
"requires": {
"debug": "^4.3.1",
"hpagent": "^0.1.1",
"ms": "^2.1.3",
"secure-json-parse": "^2.4.0"
},
"dependencies": {
"ms": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="
}
}
},
"@eslint/eslintrc": {
"version": "0.4.3",
"resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-0.4.3.tgz",
......@@ -14212,6 +14271,12 @@
"uuid": "8.3.2"
}
},
"@nestjs/elasticsearch": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/@nestjs/elasticsearch/-/elasticsearch-8.0.0.tgz",
"integrity": "sha512-Yr0DldZA2pZGAF77R7CDClbXJd6cKctI5zgFc/6vFARjaHhRwETyeTES/nRiQLCZ+hfWmpRyvu1YX3reNMqW6A==",
"requires": {}
},
"@nestjs/mapped-types": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/@nestjs/mapped-types/-/mapped-types-1.0.0.tgz",
......@@ -17568,6 +17633,11 @@
}
}
},
"hpagent": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/hpagent/-/hpagent-0.1.2.tgz",
"integrity": "sha512-ePqFXHtSQWAFXYmj+JtOTHr84iNrII4/QRlAAPPE+zqnKy4xJo7Ie1Y4kC7AdB+LxLxSTTzBMASsEcy0q8YyvQ=="
},
"html-encoding-sniffer": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-2.0.1.tgz",
......@@ -20133,6 +20203,11 @@
"resolved": "https://registry.npmjs.org/schemastery/-/schemastery-2.1.2.tgz",
"integrity": "sha512-iHwWfKxWaTFgZmKNULNtgyo8VDpdEWx31b6+j0tGTST8dBIYU7VYAHmq5qdYKYZ0uNSM5u57c09cuN75Yf7WwQ=="
},
"secure-json-parse": {
"version": "2.4.0",
"resolved": "https://registry.npmjs.org/secure-json-parse/-/secure-json-parse-2.4.0.tgz",
"integrity": "sha512-Q5Z/97nbON5t/L/sH6mY2EacfjVGwrCcSi5D3btRO2GZ8pf1K1UN7Z9H5J57hjVU2Qzxr1xO+FmBhOvEkzCMmg=="
},
"semver": {
"version": "7.3.5",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz",
......
......@@ -7,6 +7,7 @@ import { Adapter } from 'koishi';
import { AdapterConfig } from './onebot-improved/utils';
import { MessageService } from './message/message.service';
import S3Assets from '@koishijs/plugin-assets-s3';
import { ElasticsearchModule } from '@nestjs/elasticsearch';
@Module({
imports: [
......@@ -15,6 +16,9 @@ import S3Assets from '@koishijs/plugin-assets-s3';
load: [loadConfig],
isGlobal: true,
}),
ElasticsearchModule.register({
node: 'http://poi.lan:9200',
}),
KoishiModule.registerAsync({
inject: [ConfigService],
useFactory: async (configService: ConfigService) => {
......
......@@ -6,12 +6,14 @@ import {
import { UseEvent, WireContextService } from 'koishi-nestjs';
import { Session } from 'koishi';
import S3Assets from '@koishijs/plugin-assets-s3';
import { ElasticsearchService } from '@nestjs/elasticsearch';
@Injectable()
export class MessageService
extends ConsoleLogger
implements OnApplicationBootstrap {
constructor() {
implements OnApplicationBootstrap
{
constructor(private readonly elasticsearchService: ElasticsearchService) {
super('message');
}
......@@ -38,6 +40,15 @@ export class MessageService
this.log(
`Received message from ${session.username}(${fromId}) to ${targetId}: ${content}`,
);
await this.elasticsearchService.index({
index: session.bot.selfId,
body: {
fromId,
targetId,
content,
},
});
}
@WireContextService()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment