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

es

parent a27d3224
Pipeline #8116 passed with stages
in 4 minutes and 10 seconds
...@@ -9,10 +9,12 @@ ...@@ -9,10 +9,12 @@
"version": "0.0.1", "version": "0.0.1",
"license": "UNLICENSED", "license": "UNLICENSED",
"dependencies": { "dependencies": {
"@elastic/elasticsearch": "^7.16.0",
"@koishijs/plugin-assets-s3": "^1.0.0-beta.4", "@koishijs/plugin-assets-s3": "^1.0.0-beta.4",
"@nestjs/common": "^8.0.0", "@nestjs/common": "^8.0.0",
"@nestjs/config": "^1.1.5", "@nestjs/config": "^1.1.5",
"@nestjs/core": "^8.0.0", "@nestjs/core": "^8.0.0",
"@nestjs/elasticsearch": "^8.0.0",
"@nestjs/platform-express": "^8.0.0", "@nestjs/platform-express": "^8.0.0",
"@nestjs/platform-ws": "^8.2.4", "@nestjs/platform-ws": "^8.2.4",
"@nestjs/swagger": "^5.1.5", "@nestjs/swagger": "^5.1.5",
...@@ -1904,6 +1906,25 @@ ...@@ -1904,6 +1906,25 @@
"node": ">=12" "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": { "node_modules/@eslint/eslintrc": {
"version": "0.4.3", "version": "0.4.3",
"resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-0.4.3.tgz", "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-0.4.3.tgz",
...@@ -2629,6 +2650,16 @@ ...@@ -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": { "node_modules/@nestjs/mapped-types": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/@nestjs/mapped-types/-/mapped-types-1.0.0.tgz", "resolved": "https://registry.npmjs.org/@nestjs/mapped-types/-/mapped-types-1.0.0.tgz",
...@@ -6954,6 +6985,11 @@ ...@@ -6954,6 +6985,11 @@
"safe-buffer": "~5.2.0" "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": { "node_modules/html-encoding-sniffer": {
"version": "2.0.1", "version": "2.0.1",
"resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-2.0.1.tgz", "resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-2.0.1.tgz",
...@@ -10301,6 +10337,11 @@ ...@@ -10301,6 +10337,11 @@
"resolved": "https://registry.npmjs.org/schemastery/-/schemastery-2.1.2.tgz", "resolved": "https://registry.npmjs.org/schemastery/-/schemastery-2.1.2.tgz",
"integrity": "sha512-iHwWfKxWaTFgZmKNULNtgyo8VDpdEWx31b6+j0tGTST8dBIYU7VYAHmq5qdYKYZ0uNSM5u57c09cuN75Yf7WwQ==" "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": { "node_modules/semver": {
"version": "7.3.5", "version": "7.3.5",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz",
...@@ -13659,6 +13700,24 @@ ...@@ -13659,6 +13700,24 @@
"@cspotcode/source-map-consumer": "0.8.0" "@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": { "@eslint/eslintrc": {
"version": "0.4.3", "version": "0.4.3",
"resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-0.4.3.tgz", "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-0.4.3.tgz",
...@@ -14212,6 +14271,12 @@ ...@@ -14212,6 +14271,12 @@
"uuid": "8.3.2" "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": { "@nestjs/mapped-types": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/@nestjs/mapped-types/-/mapped-types-1.0.0.tgz", "resolved": "https://registry.npmjs.org/@nestjs/mapped-types/-/mapped-types-1.0.0.tgz",
...@@ -17568,6 +17633,11 @@ ...@@ -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": { "html-encoding-sniffer": {
"version": "2.0.1", "version": "2.0.1",
"resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-2.0.1.tgz", "resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-2.0.1.tgz",
...@@ -20133,6 +20203,11 @@ ...@@ -20133,6 +20203,11 @@
"resolved": "https://registry.npmjs.org/schemastery/-/schemastery-2.1.2.tgz", "resolved": "https://registry.npmjs.org/schemastery/-/schemastery-2.1.2.tgz",
"integrity": "sha512-iHwWfKxWaTFgZmKNULNtgyo8VDpdEWx31b6+j0tGTST8dBIYU7VYAHmq5qdYKYZ0uNSM5u57c09cuN75Yf7WwQ==" "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": { "semver": {
"version": "7.3.5", "version": "7.3.5",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz",
......
...@@ -21,10 +21,12 @@ ...@@ -21,10 +21,12 @@
"test:e2e": "jest --config ./test/jest-e2e.json" "test:e2e": "jest --config ./test/jest-e2e.json"
}, },
"dependencies": { "dependencies": {
"@elastic/elasticsearch": "^7.16.0",
"@koishijs/plugin-assets-s3": "^1.0.0-beta.4", "@koishijs/plugin-assets-s3": "^1.0.0-beta.4",
"@nestjs/common": "^8.0.0", "@nestjs/common": "^8.0.0",
"@nestjs/config": "^1.1.5", "@nestjs/config": "^1.1.5",
"@nestjs/core": "^8.0.0", "@nestjs/core": "^8.0.0",
"@nestjs/elasticsearch": "^8.0.0",
"@nestjs/platform-express": "^8.0.0", "@nestjs/platform-express": "^8.0.0",
"@nestjs/platform-ws": "^8.2.4", "@nestjs/platform-ws": "^8.2.4",
"@nestjs/swagger": "^5.1.5", "@nestjs/swagger": "^5.1.5",
......
...@@ -7,6 +7,7 @@ import { Adapter } from 'koishi'; ...@@ -7,6 +7,7 @@ import { Adapter } from 'koishi';
import { AdapterConfig } from './onebot-improved/utils'; import { AdapterConfig } from './onebot-improved/utils';
import { MessageService } from './message/message.service'; import { MessageService } from './message/message.service';
import S3Assets from '@koishijs/plugin-assets-s3'; import S3Assets from '@koishijs/plugin-assets-s3';
import { ElasticsearchModule } from '@nestjs/elasticsearch';
@Module({ @Module({
imports: [ imports: [
...@@ -15,6 +16,9 @@ import S3Assets from '@koishijs/plugin-assets-s3'; ...@@ -15,6 +16,9 @@ import S3Assets from '@koishijs/plugin-assets-s3';
load: [loadConfig], load: [loadConfig],
isGlobal: true, isGlobal: true,
}), }),
ElasticsearchModule.register({
node: 'http://poi.lan:9200',
}),
KoishiModule.registerAsync({ KoishiModule.registerAsync({
inject: [ConfigService], inject: [ConfigService],
useFactory: async (configService: ConfigService) => { useFactory: async (configService: ConfigService) => {
......
...@@ -6,12 +6,14 @@ import { ...@@ -6,12 +6,14 @@ import {
import { UseEvent, WireContextService } from 'koishi-nestjs'; import { UseEvent, WireContextService } from 'koishi-nestjs';
import { Session } from 'koishi'; import { Session } from 'koishi';
import S3Assets from '@koishijs/plugin-assets-s3'; import S3Assets from '@koishijs/plugin-assets-s3';
import { ElasticsearchService } from '@nestjs/elasticsearch';
@Injectable() @Injectable()
export class MessageService export class MessageService
extends ConsoleLogger extends ConsoleLogger
implements OnApplicationBootstrap { implements OnApplicationBootstrap
constructor() { {
constructor(private readonly elasticsearchService: ElasticsearchService) {
super('message'); super('message');
} }
...@@ -38,6 +40,15 @@ export class MessageService ...@@ -38,6 +40,15 @@ export class MessageService
this.log( this.log(
`Received message from ${session.username}(${fromId}) to ${targetId}: ${content}`, `Received message from ${session.username}(${fromId}) to ${targetId}: ${content}`,
); );
await this.elasticsearchService.index({
index: session.bot.selfId,
body: {
fromId,
targetId,
content,
},
});
} }
@WireContextService() @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