Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
K
koishi-plugin-ygotournament
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
3rdeye
koishi-plugin-ygotournament
Commits
a470da9c
Commit
a470da9c
authored
Nov 03, 2021
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
finish
parent
3cc4eb3f
Changes
7
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
288 additions
and
40 deletions
+288
-40
package-lock.json
package-lock.json
+64
-8
package.json
package.json
+3
-0
src/config.ts
src/config.ts
+28
-3
src/def/challonge.ts
src/def/challonge.ts
+5
-1
src/def/selection.ts
src/def/selection.ts
+20
-0
src/plugin.ts
src/plugin.ts
+164
-28
webpack.config.js
webpack.config.js
+4
-0
No files found.
package-lock.json
View file @
a470da9c
...
@@ -17,17 +17,20 @@
...
@@ -17,17 +17,20 @@
"@aws-sdk/util-format-url"
:
"^3.38.0"
,
"@aws-sdk/util-format-url"
:
"^3.38.0"
,
"class-transformer"
:
"^0.4.0"
,
"class-transformer"
:
"^0.4.0"
,
"koishi-utils-schemagen"
:
"^1.1.9"
,
"koishi-utils-schemagen"
:
"^1.1.9"
,
"moment"
:
"^2.29.1"
,
"source-map-support"
:
"^0.5.20"
"source-map-support"
:
"^0.5.20"
},
},
"devDependencies"
:
{
"devDependencies"
:
{
"@types/node"
:
"^16.11.6"
,
"@types/node"
:
"^16.11.6"
,
"@typescript-eslint/eslint-plugin"
:
"^4.33.0"
,
"@typescript-eslint/eslint-plugin"
:
"^4.33.0"
,
"@typescript-eslint/parser"
:
"^4.33.0"
,
"@typescript-eslint/parser"
:
"^4.33.0"
,
"axios"
:
"^0.24.0"
,
"eslint"
:
"^7.32.0"
,
"eslint"
:
"^7.32.0"
,
"eslint-config-prettier"
:
"^8.3.0"
,
"eslint-config-prettier"
:
"^8.3.0"
,
"eslint-plugin-prettier"
:
"^3.4.1"
,
"eslint-plugin-prettier"
:
"^3.4.1"
,
"koishi"
:
"^4.0.0-alpha.12"
,
"koishi"
:
"^4.0.0-alpha.12"
,
"prettier"
:
"^2.4.1"
,
"prettier"
:
"^2.4.1"
,
"proxy-agent"
:
"^5.0.0"
,
"raw-loader"
:
"^4.0.2"
,
"raw-loader"
:
"^4.0.2"
,
"ts-loader"
:
"^9.2.6"
,
"ts-loader"
:
"^9.2.6"
,
"typescript"
:
"^4.4.4"
,
"typescript"
:
"^4.4.4"
,
...
@@ -2140,6 +2143,15 @@
...
@@ -2140,6 +2143,15 @@
"websocket-stream"
:
"^5.5.2"
"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"
:
{
"node_modules/aws-sign2"
:
{
"version"
:
"0.7.0"
,
"version"
:
"0.7.0"
,
"resolved"
:
"https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz"
,
"resolved"
:
"https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz"
,
...
@@ -2156,11 +2168,12 @@
...
@@ -2156,11 +2168,12 @@
"peer"
:
true
"peer"
:
true
},
},
"node_modules/axios"
:
{
"node_modules/axios"
:
{
"version"
:
"0.21.4"
,
"version"
:
"0.24.0"
,
"resolved"
:
"https://registry.npmjs.org/axios/-/axios-0.21.4.tgz"
,
"resolved"
:
"https://registry.npmjs.org/axios/-/axios-0.24.0.tgz"
,
"integrity"
:
"sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg=="
,
"integrity"
:
"sha512-Q6cWsys88HoPgAaFAVUb0WpPk0O8iTeisR9IMqy9G8AbO4NlpVknrnQS03zzF9PGAWgO3cgletO3VjV/P7VztA=="
,
"dev"
:
true
,
"dependencies"
:
{
"dependencies"
:
{
"follow-redirects"
:
"^1.14.
0
"
"follow-redirects"
:
"^1.14.
4
"
}
}
},
},
"node_modules/balanced-match"
:
{
"node_modules/balanced-match"
:
{
...
@@ -4771,6 +4784,14 @@
...
@@ -4771,6 +4784,14 @@
"reflect-metadata"
:
"^0.1.13"
"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"
:
{
"node_modules/lcid"
:
{
"version"
:
"1.0.0"
,
"version"
:
"1.0.0"
,
"resolved"
:
"https://registry.npmjs.org/lcid/-/lcid-1.0.0.tgz"
,
"resolved"
:
"https://registry.npmjs.org/lcid/-/lcid-1.0.0.tgz"
,
...
@@ -5044,6 +5065,14 @@
...
@@ -5044,6 +5065,14 @@
"node"
:
">=10"
"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"
:
{
"node_modules/mqtt"
:
{
"version"
:
"4.2.8"
,
"version"
:
"4.2.8"
,
"resolved"
:
"https://registry.npmjs.org/mqtt/-/mqtt-4.2.8.tgz"
,
"resolved"
:
"https://registry.npmjs.org/mqtt/-/mqtt-4.2.8.tgz"
,
...
@@ -8892,6 +8921,17 @@
...
@@ -8892,6 +8921,17 @@
"mqtt"
:
"^4.2.8"
,
"mqtt"
:
"^4.2.8"
,
"tar"
:
"^6.1.11"
,
"tar"
:
"^6.1.11"
,
"websocket-stream"
:
"^5.5.2"
"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"
:
{
"aws-sign2"
:
{
...
@@ -8907,11 +8947,12 @@
...
@@ -8907,11 +8947,12 @@
"peer"
:
true
"peer"
:
true
},
},
"axios"
:
{
"axios"
:
{
"version"
:
"0.21.4"
,
"version"
:
"0.24.0"
,
"resolved"
:
"https://registry.npmjs.org/axios/-/axios-0.21.4.tgz"
,
"resolved"
:
"https://registry.npmjs.org/axios/-/axios-0.24.0.tgz"
,
"integrity"
:
"sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg=="
,
"integrity"
:
"sha512-Q6cWsys88HoPgAaFAVUb0WpPk0O8iTeisR9IMqy9G8AbO4NlpVknrnQS03zzF9PGAWgO3cgletO3VjV/P7VztA=="
,
"dev"
:
true
,
"requires"
:
{
"requires"
:
{
"follow-redirects"
:
"^1.14.
0
"
"follow-redirects"
:
"^1.14.
4
"
}
}
},
},
"balanced-match"
:
{
"balanced-match"
:
{
...
@@ -10870,6 +10911,16 @@
...
@@ -10870,6 +10911,16 @@
"parseurl"
:
"^1.3.3"
,
"parseurl"
:
"^1.3.3"
,
"path-to-regexp"
:
"^6.2.0"
,
"path-to-regexp"
:
"^6.2.0"
,
"proxy-agent"
:
"^5.0.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"
:
{
"koishi-utils-schemagen"
:
{
...
@@ -11099,6 +11150,11 @@
...
@@ -11099,6 +11150,11 @@
"integrity"
:
"sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw=="
,
"integrity"
:
"sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw=="
,
"peer"
:
true
"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"
:
{
"mqtt"
:
{
"version"
:
"4.2.8"
,
"version"
:
"4.2.8"
,
"resolved"
:
"https://registry.npmjs.org/mqtt/-/mqtt-4.2.8.tgz"
,
"resolved"
:
"https://registry.npmjs.org/mqtt/-/mqtt-4.2.8.tgz"
,
...
...
package.json
View file @
a470da9c
...
@@ -36,6 +36,7 @@
...
@@ -36,6 +36,7 @@
"
@aws-sdk/util-format-url
"
:
"
^3.38.0
"
,
"
@aws-sdk/util-format-url
"
:
"
^3.38.0
"
,
"
class-transformer
"
:
"
^0.4.0
"
,
"
class-transformer
"
:
"
^0.4.0
"
,
"
koishi-utils-schemagen
"
:
"
^1.1.9
"
,
"
koishi-utils-schemagen
"
:
"
^1.1.9
"
,
"
moment
"
:
"
^2.29.1
"
,
"
source-map-support
"
:
"
^0.5.20
"
"
source-map-support
"
:
"
^0.5.20
"
},
},
"peerDependencies"
:
{
"peerDependencies"
:
{
...
@@ -45,11 +46,13 @@
...
@@ -45,11 +46,13 @@
"
@types/node
"
:
"
^16.11.6
"
,
"
@types/node
"
:
"
^16.11.6
"
,
"
@typescript-eslint/eslint-plugin
"
:
"
^4.33.0
"
,
"
@typescript-eslint/eslint-plugin
"
:
"
^4.33.0
"
,
"
@typescript-eslint/parser
"
:
"
^4.33.0
"
,
"
@typescript-eslint/parser
"
:
"
^4.33.0
"
,
"
axios
"
:
"
^0.24.0
"
,
"
eslint
"
:
"
^7.32.0
"
,
"
eslint
"
:
"
^7.32.0
"
,
"
eslint-config-prettier
"
:
"
^8.3.0
"
,
"
eslint-config-prettier
"
:
"
^8.3.0
"
,
"
eslint-plugin-prettier
"
:
"
^3.4.1
"
,
"
eslint-plugin-prettier
"
:
"
^3.4.1
"
,
"
koishi
"
:
"
^4.0.0-alpha.12
"
,
"
koishi
"
:
"
^4.0.0-alpha.12
"
,
"
prettier
"
:
"
^2.4.1
"
,
"
prettier
"
:
"
^2.4.1
"
,
"
proxy-agent
"
:
"
^5.0.0
"
,
"
raw-loader
"
:
"
^4.0.2
"
,
"
raw-loader
"
:
"
^4.0.2
"
,
"
ts-loader
"
:
"
^9.2.6
"
,
"
ts-loader
"
:
"
^9.2.6
"
,
"
typescript
"
:
"
^4.4.4
"
,
"
typescript
"
:
"
^4.4.4
"
,
...
...
src/config.ts
View file @
a470da9c
...
@@ -11,13 +11,11 @@ import { Context, Schema } from 'koishi';
...
@@ -11,13 +11,11 @@ import { Context, Schema } from 'koishi';
import
{
import
{
GetObjectCommand
,
GetObjectCommand
,
ListObjectsCommand
,
ListObjectsCommand
,
S3
,
S3Client
,
S3Client
,
S3ClientConfig
,
S3ClientConfig
,
}
from
'
@aws-sdk/client-s3
'
;
}
from
'
@aws-sdk/client-s3
'
;
import
{
Tournament
}
from
'
./def/challonge
'
;
import
{
Type
}
from
'
class-transformer
'
;
import
{
SRVProRoomInfo
}
from
'
./def/srvpro
'
;
import
{
SRVProRoomInfo
}
from
'
./def/srvpro
'
;
import
{
Selection
}
from
'
./def/selection
'
;
const
credentialsSchema
:
Schema
<
Credentials
>
=
Schema
.
object
(
const
credentialsSchema
:
Schema
<
Credentials
>
=
Schema
.
object
(
{
{
...
@@ -106,6 +104,16 @@ export class TournamentConfig {
...
@@ -106,6 +104,16 @@ export class TournamentConfig {
})
})
challongeCacheTTL
:
number
;
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
)
{
async
fetchRooms
(
ctx
:
Context
)
{
return
ctx
.
http
.
get
<
Partial
<
SRVProRoomInfo
>>
(
return
ctx
.
http
.
get
<
Partial
<
SRVProRoomInfo
>>
(
`
${
this
.
endpoint
}
/api/getrooms`
,
`
${
this
.
endpoint
}
/api/getrooms`
,
...
@@ -115,9 +123,25 @@ export class TournamentConfig {
...
@@ -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
{
export
class
YGOTournamentPluginConfig
{
@
DefineSchema
({
type
:
'
object
'
,
allowUnknown
:
true
,
desc
:
'
裁判接口作用域
'
,
required
:
true
,
})
judgeSelection
:
Selection
;
@
DefineSchema
()
@
DefineSchema
()
tournament
:
TournamentConfig
;
tournament
:
TournamentConfig
;
...
@@ -134,6 +158,7 @@ export class YGOTournamentPluginConfig {
...
@@ -134,6 +158,7 @@ export class YGOTournamentPluginConfig {
}
}
export
interface
YGOTournamentPluginConfigLike
{
export
interface
YGOTournamentPluginConfigLike
{
judgeSelection
:
Selection
;
tournament
?:
Partial
<
TournamentConfig
>
;
tournament
?:
Partial
<
TournamentConfig
>
;
deckFetch
?:
Partial
<
DeckFetchConfig
>
;
deckFetch
?:
Partial
<
DeckFetchConfig
>
;
}
}
src/def/challonge.ts
View file @
a470da9c
...
@@ -35,7 +35,7 @@ export class MatchWrapper {
...
@@ -35,7 +35,7 @@ export class MatchWrapper {
isClean
()
{
isClean
()
{
return
(
return
(
this
.
match
.
state
!==
'
complete
'
&&
this
.
match
.
state
!==
'
complete
'
&&
(
this
.
match
.
scores_csv
?.
length
&&
0
)
<
3
(
this
.
match
.
scores_csv
?.
length
||
0
)
<
3
);
);
}
}
getPlayerIds
()
{
getPlayerIds
()
{
...
@@ -91,6 +91,10 @@ export class ParticipantWrapper {
...
@@ -91,6 +91,10 @@ export class ParticipantWrapper {
}
}
return
{
userId
:
matching
[
1
],
userName
:
matching
[
2
]
};
return
{
userId
:
matching
[
1
],
userName
:
matching
[
2
]
};
}
}
getDisplayName
()
{
return
`
${
this
.
participant
.
name
}
(
${
this
.
participant
.
id
}
)`
;
}
}
}
export
class
Tournament
{
export
class
Tournament
{
...
...
src/def/selection.ts
0 → 100644
View file @
a470da9c
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
;
}
src/plugin.ts
View file @
a470da9c
This diff is collapsed.
Click to expand it.
webpack.config.js
View file @
a470da9c
...
@@ -29,6 +29,8 @@ module.exports = {
...
@@ -29,6 +29,8 @@ module.exports = {
},
},
externals
:
{
externals
:
{
koishi
:
'
koishi
'
,
koishi
:
'
koishi
'
,
'
proxy-agent
'
:
'
proxy-agent
'
,
axios
:
'
axios
'
,
...(
packAll
...(
packAll
?
{}
?
{}
:
{
:
{
...
@@ -37,8 +39,10 @@ module.exports = {
...
@@ -37,8 +39,10 @@ module.exports = {
'
@aws-sdk/protocol-http
'
:
'
@aws-sdk/protocol-http
'
,
'
@aws-sdk/protocol-http
'
:
'
@aws-sdk/protocol-http
'
,
'
@aws-sdk/smithy-client
'
:
'
@aws-sdk/smithy-client
'
,
'
@aws-sdk/smithy-client
'
:
'
@aws-sdk/smithy-client
'
,
'
@aws-sdk/util-format-url
'
:
'
@aws-sdk/util-format-url
'
,
'
@aws-sdk/util-format-url
'
:
'
@aws-sdk/util-format-url
'
,
'
@aws-sdk/types
'
:
'
@aws-sdk/types
'
,
'
koishi-utils-schemagen
'
:
'
koishi-utils-schemagen
'
,
'
koishi-utils-schemagen
'
:
'
koishi-utils-schemagen
'
,
'
class-transformer
'
:
'
class-transformer
'
,
'
class-transformer
'
:
'
class-transformer
'
,
moment
:
'
moment
'
,
}),
}),
},
},
};
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment