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
1cc42437
Commit
1cc42437
authored
May 28, 2022
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix cache inject
parent
5f4e8d25
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
9 deletions
+13
-9
src/index.ts
src/index.ts
+13
-9
No files found.
src/index.ts
View file @
1cc42437
...
...
@@ -7,7 +7,8 @@ import { S3Client } from '@aws-sdk/client-s3';
import
{
getSignedUrl
}
from
'
./presign
'
;
import
{
SRVProRoomInfo
}
from
'
./def/srvpro
'
;
import
moment
from
'
moment
'
;
import
{
DefinePlugin
,
StarterPlugin
}
from
'
koishi-thirdeye
'
;
import
{
DefinePlugin
,
Inject
,
StarterPlugin
}
from
'
koishi-thirdeye
'
;
import
{
Cache
}
from
'
koishi
'
;
export
interface
FromAndToTimeUnix
{
fromTime
:
number
;
...
...
@@ -28,9 +29,12 @@ declare module 'koishi' {
export
default
class
YGOTournamentPlugin
extends
StarterPlugin
(
YGOTournamentPluginConfig
,
)
{
@
Inject
(
true
)
private
cache
:
Cache
;
private
s3
:
S3Client
;
private
async
getChallongeCache
()
{
const
data
=
this
.
c
tx
.
c
ache
.
get
(
const
data
=
this
.
cache
.
get
(
'
challongeData
'
,
this
.
config
.
tournament
.
challongeTournamentId
,
);
...
...
@@ -40,14 +44,14 @@ export default class YGOTournamentPlugin extends StarterPlugin(
}
private
async
deleteChallongeCache
()
{
return
this
.
c
tx
.
c
ache
.
del
(
return
this
.
cache
.
del
(
'
challongeData
'
,
this
.
config
.
tournament
.
challongeTournamentId
,
);
}
private
async
setChallongeCache
(
data
:
TournamentWrapper
)
{
return
this
.
c
tx
.
c
ache
.
set
(
return
this
.
cache
.
set
(
'
challongeData
'
,
this
.
config
.
tournament
.
challongeTournamentId
,
classToPlain
(
data
),
...
...
@@ -154,7 +158,7 @@ export default class YGOTournamentPlugin extends StarterPlugin(
}
private
async
onUserDeclareLate
(
userId
:
string
)
{
const
timeUnix
=
await
this
.
c
tx
.
c
ache
.
get
(
'
lateDeclarationTime
'
,
'
current
'
);
const
timeUnix
=
await
this
.
cache
.
get
(
'
lateDeclarationTime
'
,
'
current
'
);
// this.ctx.logger('test').warn(JSON.stringify(timeUnix));
if
(
!
timeUnix
||
...
...
@@ -302,7 +306,7 @@ export default class YGOTournamentPlugin extends StarterPlugin(
if
(
!
this
.
config
.
isTournamentEnabled
())
{
return
;
}
this
.
c
tx
.
c
ache
.
table
(
'
lateDeclarationTime
'
,
{
maxAge
:
3600
*
1000
});
this
.
cache
.
table
(
'
lateDeclarationTime
'
,
{
maxAge
:
3600
*
1000
});
this
.
ctx
.
command
(
'
tournament/currentmatch
'
,
'
获取当前对局
'
)
.
shortcut
(
'
获取当前对局
'
)
...
...
@@ -370,7 +374,7 @@ export default class YGOTournamentPlugin extends StarterPlugin(
.
action
(
async
({
session
,
options
})
=>
{
const
fromTime
=
moment
().
add
(
options
.
delay
,
'
minutes
'
);
const
toTime
=
fromTime
.
clone
().
add
(
options
.
duration
,
'
minutes
'
);
await
this
.
c
tx
.
c
ache
.
set
(
await
this
.
cache
.
set
(
'
lateDeclarationTime
'
,
'
current
'
,
{
...
...
@@ -387,13 +391,13 @@ export default class YGOTournamentPlugin extends StarterPlugin(
.
subcommand
(
'
.disablelate
'
,
'
关闭迟到杀
'
)
.
usage
(
'
不再允许选手进行迟到杀操作。
'
)
.
action
(
async
()
=>
{
await
this
.
c
tx
.
c
ache
.
del
(
'
lateDeclarationTime
'
,
'
current
'
);
await
this
.
cache
.
del
(
'
lateDeclarationTime
'
,
'
current
'
);
return
'
设置成功。选手不再允许进行迟到杀操作。
'
;
});
judgeCommand
.
subcommand
(
'
.refresh
'
,
'
清理 Challonge 缓存
'
)
.
action
(
async
()
=>
{
await
this
.
c
tx
.
c
ache
.
del
(
await
this
.
cache
.
del
(
'
challongeData
'
,
this
.
config
.
tournament
.
challongeTournamentId
,
);
...
...
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