Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
K
Koishi Plugin Order Picker
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 Order Picker
Commits
8f8f299f
Commit
8f8f299f
authored
Jul 25, 2022
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bump to Koishi 4.8
parent
5cbeb9ff
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
1600 additions
and
524 deletions
+1600
-524
dev/index.ts
dev/index.ts
+4
-4
package-lock.json
package-lock.json
+1556
-488
package.json
package.json
+9
-7
src/index.ts
src/index.ts
+20
-22
tests/sample.spec.ts
tests/sample.spec.ts
+3
-3
webpack.config.js
webpack.config.js
+8
-0
No files found.
dev/index.ts
View file @
8f8f299f
import
{
App
}
from
'
koishi
'
;
import
{
Context
}
from
'
koishi
'
;
import
TargetPlugin
from
'
../src
'
;
import
TargetPlugin
from
'
../src
'
;
import
ConsolePlugin
from
'
@koishijs/plugin-console
'
;
import
ConsolePlugin
from
'
@koishijs/plugin-console
'
;
import
SandboxPlugin
from
'
@koishijs/plugin-sandbox
'
;
import
SandboxPlugin
from
'
@koishijs/plugin-sandbox
'
;
import
*
as
DatabasePlugin
from
'
@koishijs/plugin-database-memory
'
;
import
DatabasePlugin
from
'
@koishijs/plugin-database-memory
'
;
import
CachePlugin
from
'
@koishijs/plugin-cache-lru
'
;
import
CachePlugin
from
'
koishi-plugin-cache-aragami
'
;
import
ExtrasInDev
from
'
./extras
'
;
import
ExtrasInDev
from
'
./extras
'
;
const
app
=
new
App
({
const
app
=
new
Context
({
port
:
14514
,
port
:
14514
,
host
:
'
localhost
'
,
host
:
'
localhost
'
,
prefix
:
'
.
'
,
prefix
:
'
.
'
,
...
...
package-lock.json
View file @
8f8f299f
This source diff could not be displayed because it is too large. You can
view the blob
instead.
package.json
View file @
8f8f299f
...
@@ -21,7 +21,7 @@
...
@@ -21,7 +21,7 @@
"qqbot"
,
"qqbot"
,
"cqhttp"
,
"cqhttp"
,
"onebot"
,
"onebot"
,
"required:cache"
,
"required:cache
-aragami
"
,
"market:hidden"
"market:hidden"
],
],
"bugs"
:
{
"bugs"
:
{
...
@@ -29,22 +29,23 @@
...
@@ -29,22 +29,23 @@
},
},
"homepage"
:
"
https://code.mycard.moe/3rdeye/koishi-plugin-order-picker
"
,
"homepage"
:
"
https://code.mycard.moe/3rdeye/koishi-plugin-order-picker
"
,
"dependencies"
:
{
"dependencies"
:
{
"
koishi-thirdeye
"
:
"
^1
0.3.2
"
,
"
koishi-thirdeye
"
:
"
^1
1.0.6
"
,
"
moment
"
:
"
^2.29.1
"
"
moment
"
:
"
^2.29.1
"
},
},
"devDependencies"
:
{
"devDependencies"
:
{
"
@koishijs/plugin-cache-lru
"
:
"
^1.0.0-rc.0
"
,
"
@koishijs/plugin-console
"
:
"
^4.1.1
"
,
"
@koishijs/plugin-console
"
:
"
^3.3.2
"
,
"
@koishijs/plugin-database-memory
"
:
"
^1.4.1
"
,
"
@koishijs/plugin-database-memory
"
:
"
^1.3.0
"
,
"
@koishijs/plugin-sandbox
"
:
"
^2.0.1
"
,
"
@koishijs/plugin-sandbox
"
:
"
^1.1.3
"
,
"
@types/jest
"
:
"
^27.4.0
"
,
"
@types/jest
"
:
"
^27.4.0
"
,
"
@types/node
"
:
"
^17.0.2
"
,
"
@types/node
"
:
"
^17.0.2
"
,
"
@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
"
,
"
esbuild-loader
"
:
"
^2.19.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
"
,
"
jest
"
:
"
^27.5.1
"
,
"
jest
"
:
"
^27.5.1
"
,
"
koishi-plugin-cache-aragami
"
:
"
^1.0.4
"
,
"
prettier
"
:
"
^2.5.1
"
,
"
prettier
"
:
"
^2.5.1
"
,
"
raw-loader
"
:
"
^4.0.2
"
,
"
raw-loader
"
:
"
^4.0.2
"
,
"
ts-jest
"
:
"
^27.1.3
"
,
"
ts-jest
"
:
"
^27.1.3
"
,
...
@@ -56,7 +57,8 @@
...
@@ -56,7 +57,8 @@
"
ws
"
:
"
^8.4.0
"
"
ws
"
:
"
^8.4.0
"
},
},
"peerDependencies"
:
{
"peerDependencies"
:
{
"koishi"
:
"^4.7.5"
"koishi"
:
"^4.8.2"
,
"
koishi-plugin-cache-aragami
"
:
"
^1.0.4
"
},
},
"jest"
:
{
"jest"
:
{
"moduleFileExtensions"
:
[
"moduleFileExtensions"
:
[
...
...
src/index.ts
View file @
8f8f299f
// import 'source-map-support/register';
// import 'source-map-support/register';
import
{
Context
,
Cache
,
Session
,
Next
,
Bo
t
,
segment
}
from
'
koishi
'
;
import
{
Context
,
Session
,
Nex
t
,
segment
}
from
'
koishi
'
;
import
{
OrderPickerConfig
,
OrderPickerConfigLike
}
from
'
./config
'
;
import
{
OrderPickerConfig
,
OrderPickerConfigLike
}
from
'
./config
'
;
import
{
import
{
DefinePlugin
,
DefinePlugin
,
...
@@ -8,44 +8,39 @@ import {
...
@@ -8,44 +8,39 @@ import {
UseMiddleware
,
UseMiddleware
,
OnGuild
,
OnGuild
,
OnPlatform
,
OnPlatform
,
OnApply
,
LifecycleEvents
,
}
from
'
koishi-thirdeye
'
;
}
from
'
koishi-thirdeye
'
;
import
moment
from
'
moment
'
;
import
moment
from
'
moment
'
;
export
*
from
'
./config
'
;
export
*
from
'
./config
'
;
import
AragamiPlugin
,
{
CacheKey
}
from
'
koishi-plugin-cache-aragami
'
;
export
interface
PickedOrderInfo
{
export
class
PickedOrderInfo
{
sourceGuildId
:
string
;
sourceGuildId
:
string
;
@
CacheKey
()
sourceUserId
:
string
;
sourceUserId
:
string
;
sourceUserName
:
string
;
sourceUserName
:
string
;
description
:
string
;
description
:
string
;
time
:
number
;
time
:
number
;
}
}
declare
module
'
koishi
'
{
export
class
SelfOnline
{
// eslint-disable-next-line @typescript-eslint/no-namespace
@
CacheKey
()
namespace
Cache
{
selfId
:
string
;
interface
Tables
{
orderPickerOnline
:
boolean
;
online
:
boolean
;
pickedOrderInfo
:
PickedOrderInfo
;
}
}
}
}
@
OnPlatform
(
'
onebot
'
)
@
OnPlatform
(
'
onebot
'
)
@
DefinePlugin
({
name
:
'
order-picker
'
,
schema
:
OrderPickerConfig
})
@
DefinePlugin
({
name
:
'
order-picker
'
,
schema
:
OrderPickerConfig
})
export
default
class
OrderPicker
implements
OnApply
{
export
default
class
OrderPicker
implements
LifecycleEvents
{
constructor
(
private
ctx
:
Context
,
config
:
OrderPickerConfigLike
)
{}
constructor
(
private
ctx
:
Context
,
config
:
OrderPickerConfigLike
)
{}
@
InjectConfig
()
@
InjectConfig
()
private
config
:
OrderPickerConfig
;
private
config
:
OrderPickerConfig
;
@
Inject
(
true
)
@
Inject
(
true
)
private
cache
:
Cache
;
private
aragami
:
AragamiPlugin
;
onApply
()
{
onApply
()
{
this
.
cache
.
table
(
'
orderPickerOnline
'
,
{});
this
.
cache
.
table
(
'
pickedOrderInfo
'
,
{
maxAge
:
1000
*
60
*
this
.
config
.
cooldown
,
});
const
cmd
=
this
.
ctx
const
cmd
=
this
.
ctx
.
private
(
this
.
config
.
masterId
)
.
private
(
this
.
config
.
masterId
)
.
command
(
'
order-picker
'
,
'
抢单管理
'
);
.
command
(
'
order-picker
'
,
'
抢单管理
'
);
...
@@ -108,23 +103,26 @@ export default class OrderPicker implements OnApply {
...
@@ -108,23 +103,26 @@ export default class OrderPicker implements OnApply {
}
}
private
async
getLastInfo
(
selfId
:
string
)
{
private
async
getLastInfo
(
selfId
:
string
)
{
return
this
.
cache
.
get
(
'
pickedOrderInfo
'
,
selfId
);
return
this
.
aragami
.
get
(
PickedOrderInfo
,
selfId
);
}
}
private
async
setLastInfo
(
selfId
:
string
,
info
:
PickedOrderInfo
)
{
private
async
setLastInfo
(
selfId
:
string
,
info
:
PickedOrderInfo
)
{
return
this
.
cache
.
set
(
'
pickedOrderInfo
'
,
selfId
,
info
);
return
this
.
aragami
.
set
(
PickedOrderInfo
,
info
,
{
ttl
:
this
.
config
.
cooldown
*
60
*
1000
,
});
}
}
private
async
removeLastInfo
(
selfId
:
string
)
{
private
async
removeLastInfo
(
selfId
:
string
)
{
return
this
.
cache
.
del
(
'
pickedOrderInfo
'
,
selfId
);
return
this
.
aragami
.
del
(
PickedOrderInfo
,
selfId
);
}
}
private
async
isOnline
(
selfId
:
string
)
{
private
async
isOnline
(
selfId
:
string
)
{
return
this
.
cache
.
get
(
'
orderPickerOnline
'
,
selfId
);
const
online
=
await
this
.
aragami
.
get
(
SelfOnline
,
selfId
);
return
!!
online
?.
online
;
}
}
private
async
setOnline
(
selfId
:
string
,
online
:
boolean
)
{
private
async
setOnline
(
selfId
:
string
,
online
:
boolean
)
{
return
this
.
cache
.
set
(
'
orderPickerOnline
'
,
selfId
,
online
);
await
this
.
aragami
.
set
(
SelfOnline
,
{
selfId
,
online
}
);
}
}
@
OnGuild
()
@
OnGuild
()
...
...
tests/sample.spec.ts
View file @
8f8f299f
import
{
App
}
from
'
koishi
'
;
import
{
Context
}
from
'
koishi
'
;
import
TargetPlugin
from
'
../src
'
;
import
TargetPlugin
from
'
../src
'
;
describe
(
'
Test of plugin.
'
,
()
=>
{
describe
(
'
Test of plugin.
'
,
()
=>
{
let
app
:
App
;
let
app
:
Context
;
beforeEach
(
async
()
=>
{
beforeEach
(
async
()
=>
{
app
=
new
App
();
app
=
new
Context
();
// app.plugin(TargetPlugin);
// app.plugin(TargetPlugin);
await
app
.
start
();
await
app
.
start
();
});
});
...
...
webpack.config.js
View file @
8f8f299f
const
path
=
require
(
'
path
'
);
const
path
=
require
(
'
path
'
);
const
packgeInfo
=
require
(
'
./package.json
'
);
const
packgeInfo
=
require
(
'
./package.json
'
);
const
{
ESBuildMinifyPlugin
}
=
require
(
'
esbuild-loader
'
);
function
externalsFromDep
()
{
function
externalsFromDep
()
{
return
Object
.
fromEntries
(
return
Object
.
fromEntries
(
...
@@ -43,4 +44,11 @@ module.exports = {
...
@@ -43,4 +44,11 @@ module.exports = {
koishi
:
'
koishi
'
,
koishi
:
'
koishi
'
,
...(
packAll
?
{}
:
externalsFromDep
()),
...(
packAll
?
{}
:
externalsFromDep
()),
},
},
optimization
:
{
minimizer
:
[
new
ESBuildMinifyPlugin
({
keepNames
:
true
,
}),
],
},
};
};
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