Commit a470da9c authored by nanahira's avatar nanahira

finish

parent 3cc4eb3f
......@@ -17,17 +17,20 @@
"@aws-sdk/util-format-url": "^3.38.0",
"class-transformer": "^0.4.0",
"koishi-utils-schemagen": "^1.1.9",
"moment": "^2.29.1",
"source-map-support": "^0.5.20"
},
"devDependencies": {
"@types/node": "^16.11.6",
"@typescript-eslint/eslint-plugin": "^4.33.0",
"@typescript-eslint/parser": "^4.33.0",
"axios": "^0.24.0",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^3.4.1",
"koishi": "^4.0.0-alpha.12",
"prettier": "^2.4.1",
"proxy-agent": "^5.0.0",
"raw-loader": "^4.0.2",
"ts-loader": "^9.2.6",
"typescript": "^4.4.4",
......@@ -2140,6 +2143,15 @@
"websocket-stream": "^5.5.2"
}
},
"node_modules/aws-crt/node_modules/axios": {
"version": "0.21.4",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.21.4.tgz",
"integrity": "sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==",
"peer": true,
"dependencies": {
"follow-redirects": "^1.14.0"
}
},
"node_modules/aws-sign2": {
"version": "0.7.0",
"resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz",
......@@ -2156,11 +2168,12 @@
"peer": true
},
"node_modules/axios": {
"version": "0.21.4",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.21.4.tgz",
"integrity": "sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==",
"version": "0.24.0",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.24.0.tgz",
"integrity": "sha512-Q6cWsys88HoPgAaFAVUb0WpPk0O8iTeisR9IMqy9G8AbO4NlpVknrnQS03zzF9PGAWgO3cgletO3VjV/P7VztA==",
"dev": true,
"dependencies": {
"follow-redirects": "^1.14.0"
"follow-redirects": "^1.14.4"
}
},
"node_modules/balanced-match": {
......@@ -4771,6 +4784,14 @@
"reflect-metadata": "^0.1.13"
}
},
"node_modules/koishi/node_modules/axios": {
"version": "0.21.4",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.21.4.tgz",
"integrity": "sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==",
"dependencies": {
"follow-redirects": "^1.14.0"
}
},
"node_modules/lcid": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/lcid/-/lcid-1.0.0.tgz",
......@@ -5044,6 +5065,14 @@
"node": ">=10"
}
},
"node_modules/moment": {
"version": "2.29.1",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.29.1.tgz",
"integrity": "sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ==",
"engines": {
"node": "*"
}
},
"node_modules/mqtt": {
"version": "4.2.8",
"resolved": "https://registry.npmjs.org/mqtt/-/mqtt-4.2.8.tgz",
......@@ -8892,6 +8921,17 @@
"mqtt": "^4.2.8",
"tar": "^6.1.11",
"websocket-stream": "^5.5.2"
},
"dependencies": {
"axios": {
"version": "0.21.4",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.21.4.tgz",
"integrity": "sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==",
"peer": true,
"requires": {
"follow-redirects": "^1.14.0"
}
}
}
},
"aws-sign2": {
......@@ -8907,11 +8947,12 @@
"peer": true
},
"axios": {
"version": "0.21.4",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.21.4.tgz",
"integrity": "sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==",
"version": "0.24.0",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.24.0.tgz",
"integrity": "sha512-Q6cWsys88HoPgAaFAVUb0WpPk0O8iTeisR9IMqy9G8AbO4NlpVknrnQS03zzF9PGAWgO3cgletO3VjV/P7VztA==",
"dev": true,
"requires": {
"follow-redirects": "^1.14.0"
"follow-redirects": "^1.14.4"
}
},
"balanced-match": {
......@@ -10870,6 +10911,16 @@
"parseurl": "^1.3.3",
"path-to-regexp": "^6.2.0",
"proxy-agent": "^5.0.0"
},
"dependencies": {
"axios": {
"version": "0.21.4",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.21.4.tgz",
"integrity": "sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==",
"requires": {
"follow-redirects": "^1.14.0"
}
}
}
},
"koishi-utils-schemagen": {
......@@ -11099,6 +11150,11 @@
"integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==",
"peer": true
},
"moment": {
"version": "2.29.1",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.29.1.tgz",
"integrity": "sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ=="
},
"mqtt": {
"version": "4.2.8",
"resolved": "https://registry.npmjs.org/mqtt/-/mqtt-4.2.8.tgz",
......
......@@ -11,13 +11,11 @@ import { Context, Schema } from 'koishi';
import {
GetObjectCommand,
ListObjectsCommand,
S3,
S3Client,
S3ClientConfig,
} from '@aws-sdk/client-s3';
import { Tournament } from './def/challonge';
import { Type } from 'class-transformer';
import { SRVProRoomInfo } from './def/srvpro';
import { Selection } from './def/selection';
const credentialsSchema: Schema<Credentials> = Schema.object(
{
......@@ -106,6 +104,16 @@ export class TournamentConfig {
})
challongeCacheTTL: number;
@DefineSchema({
desc: 'Challonge URL 前缀',
default: 'https://api.challonge.com/v1/tournaments/',
})
challongeUrlPrefix: string;
getChallongeUrl() {
return `${this.challongeUrlPrefix}${this.challongeTournamentId}`;
}
async fetchRooms(ctx: Context) {
return ctx.http.get<Partial<SRVProRoomInfo>>(
`${this.endpoint}/api/getrooms`,
......@@ -115,9 +123,25 @@ export class TournamentConfig {
},
);
}
async kickRoom(ctx: Context, search: string) {
return ctx.http.get(`${this.endpoint}/api/message`, {
username: this.username,
pass: this.password,
kick: search,
});
}
}
export class YGOTournamentPluginConfig {
@DefineSchema({
type: 'object',
allowUnknown: true,
desc: '裁判接口作用域',
required: true,
})
judgeSelection: Selection;
@DefineSchema()
tournament: TournamentConfig;
......@@ -134,6 +158,7 @@ export class YGOTournamentPluginConfig {
}
export interface YGOTournamentPluginConfigLike {
judgeSelection: Selection;
tournament?: Partial<TournamentConfig>;
deckFetch?: Partial<DeckFetchConfig>;
}
......@@ -35,7 +35,7 @@ export class MatchWrapper {
isClean() {
return (
this.match.state !== 'complete' &&
(this.match.scores_csv?.length && 0) < 3
(this.match.scores_csv?.length || 0) < 3
);
}
getPlayerIds() {
......@@ -91,6 +91,10 @@ export class ParticipantWrapper {
}
return { userId: matching[1], userName: matching[2] };
}
getDisplayName() {
return `${this.participant.name}(${this.participant.id})`;
}
}
export class Tournament {
......
import { MaybeArray } from 'koishi';
const selectors = [
'user',
'guild',
'channel',
'self',
'private',
'platform',
] as const;
type SelectorType = typeof selectors[number];
type SelectorValue = boolean | MaybeArray<string | number>;
type BaseSelection = { [K in SelectorType as `$${K}`]?: SelectorValue };
export interface Selection extends BaseSelection {
$and?: Selection[];
$or?: Selection[];
$not?: Selection;
}
This diff is collapsed.
......@@ -29,6 +29,8 @@ module.exports = {
},
externals: {
koishi: 'koishi',
'proxy-agent': 'proxy-agent',
axios: 'axios',
...(packAll
? {}
: {
......@@ -37,8 +39,10 @@ module.exports = {
'@aws-sdk/protocol-http': '@aws-sdk/protocol-http',
'@aws-sdk/smithy-client': '@aws-sdk/smithy-client',
'@aws-sdk/util-format-url': '@aws-sdk/util-format-url',
'@aws-sdk/types': '@aws-sdk/types',
'koishi-utils-schemagen': 'koishi-utils-schemagen',
'class-transformer': 'class-transformer',
moment: 'moment',
}),
},
};
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