Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
K
koishi-plugin-hisoutensoku-jammer
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
nanahira
koishi-plugin-hisoutensoku-jammer
Commits
f65b1b33
Commit
f65b1b33
authored
Jul 25, 2022
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bump to Koishi 4.8
parent
1345f6f0
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
1621 additions
and
557 deletions
+1621
-557
dev/index.ts
dev/index.ts
+4
-4
package-lock.json
package-lock.json
+1577
-518
package.json
package.json
+8
-7
src/config.ts
src/config.ts
+1
-1
src/index.ts
src/index.ts
+20
-24
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 @
f65b1b33
import
{
App
}
from
'
koishi
'
;
import
{
Context
}
from
'
koishi
'
;
import
TargetPlugin
from
'
../src
'
;
import
ConsolePlugin
from
'
@koishijs/plugin-console
'
;
import
SandboxPlugin
from
'
@koishijs/plugin-sandbox
'
;
import
*
as
DatabasePlugin
from
'
@koishijs/plugin-database-memory
'
;
import
CachePlugin
from
'
@koishijs/plugin-cache-lru
'
;
import
DatabasePlugin
from
'
@koishijs/plugin-database-memory
'
;
import
CachePlugin
from
'
koishi-plugin-cache-aragami
'
;
import
ExtrasInDev
from
'
./extras
'
;
const
app
=
new
App
({
const
app
=
new
Context
({
port
:
14514
,
host
:
'
localhost
'
,
prefix
:
'
.
'
,
...
...
package-lock.json
View file @
f65b1b33
This source diff could not be displayed because it is too large. You can
view the blob
instead.
package.json
View file @
f65b1b33
...
...
@@ -20,7 +20,7 @@
"Koishi.js"
,
"qqbot"
,
"cqhttp"
,
"required:cache"
,
"required:cache
-aragami
"
,
"market:hidden"
],
"bugs"
:
{
...
...
@@ -30,22 +30,22 @@
"dependencies"
:
{
"
crypto-random-string
"
:
"
^3.3.1
"
,
"
ip
"
:
"
^1.1.5
"
,
"
koishi-thirdeye
"
:
"
^1
0.3.2
"
,
"
koishi-thirdeye
"
:
"
^1
1.0.6
"
,
"
lodash
"
:
"
^4.17.21
"
,
"
moment
"
:
"
^2.29.1
"
,
"
tesseract.js
"
:
"
^2.1.5
"
},
"devDependencies"
:
{
"
@koishijs/plugin-cache-lru
"
:
"
^1.0.0-rc.0
"
,
"
@koishijs/plugin-console
"
:
"
^3.3.2
"
,
"
@koishijs/plugin-database-memory
"
:
"
^1.3.0
"
,
"
@koishijs/plugin-sandbox
"
:
"
^1.1.3
"
,
"
@koishijs/plugin-console
"
:
"
^4.1.1
"
,
"
@koishijs/plugin-database-memory
"
:
"
^1.4.1
"
,
"
@koishijs/plugin-sandbox
"
:
"
^2.0.1
"
,
"
@types/ip
"
:
"
^1.1.0
"
,
"
@types/jest
"
:
"
^27.4.0
"
,
"
@types/lodash
"
:
"
^4.14.177
"
,
"
@types/node
"
:
"
^16.11.9
"
,
"
@typescript-eslint/eslint-plugin
"
:
"
^4.33.0
"
,
"
@typescript-eslint/parser
"
:
"
^4.33.0
"
,
"
esbuild-loader
"
:
"
^2.19.0
"
,
"
eslint
"
:
"
^7.32.0
"
,
"
eslint-config-prettier
"
:
"
^8.3.0
"
,
"
eslint-plugin-prettier
"
:
"
^3.4.1
"
,
...
...
@@ -61,7 +61,8 @@
"
ws
"
:
"
^8.3.0
"
},
"peerDependencies"
:
{
"koishi"
:
"^4.7.5"
"koishi"
:
"^4.8.2"
,
"koishi-plugin-cache-aragami"
:
"^1.0.4"
},
"jest"
:
{
"moduleFileExtensions"
:
[
...
...
src/config.ts
View file @
f65b1b33
...
...
@@ -36,7 +36,7 @@ export class HisoutensokuJammerPluginConfig {
}
try {
const worker = createWorker({
logger: (m) => logger.
debug
(m),
logger: (m) => logger.
info
(m),
//dataPath: path.join(__dirname, '..', 'lang-data'),
...(this.ocrExtraOptions || {}),
});
...
...
src/index.ts
View file @
f65b1b33
// import 'source-map-support/register';
import
{
Logger
,
Next
,
Session
,
Cache
,
segment
}
from
'
koishi
'
;
import
{
Logger
,
Next
,
Session
,
segment
}
from
'
koishi
'
;
import
{
HisoutensokuJammerPluginConfig
}
from
'
./config
'
;
import
{
DefinePlugin
,
...
...
@@ -7,8 +7,7 @@ import {
InjectLogger
,
Inject
,
UseEvent
,
OnApply
,
BasePlugin
,
StarterPlugin
,
}
from
'
koishi-thirdeye
'
;
import
{
Attacker
}
from
'
./attacker
'
;
import
moment
from
'
moment
'
;
...
...
@@ -16,15 +15,14 @@ import { chineseCharacterList } from './chinese-replace';
import
{
Worker
}
from
'
tesseract.js
'
;
import
_
from
'
lodash
'
;
import
{
recursiveMatch
}
from
'
./utils
'
;
import
AragamiPlugin
,
{
CacheKey
,
CacheTTL
}
from
'
koishi-plugin-cache-aragami
'
;
export
*
from
'
./config
'
;
declare
module
'
koishi
'
{
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace
Cache
{
interface
Tables
{
lastMessages
:
string
;
}
}
@
CacheTTL
(
600000
)
class
LastMessage
{
@
CacheKey
()
sender
:
string
;
message
:
string
;
}
const
matcherSingle
=
...
...
@@ -36,19 +34,14 @@ const PROTOCOL_BASE64 = 'base64://';
name
:
'
hisoutensoku-jammer
'
,
schema
:
HisoutensokuJammerPluginConfig
,
})
export
default
class
HisoutensokuJammerPlugin
extends
BasePlugin
<
HisoutensokuJammerPluginConfig
>
implements
OnApply
{
export
default
class
HisoutensokuJammerPlugin
extends
StarterPlugin
(
HisoutensokuJammerPluginConfig
,
)
{
@
InjectLogger
()
private
log
:
Logger
;
@
Inject
(
'
cache
'
,
true
)
private
cache
:
Cache
;
onApply
()
{
this
.
cache
.
table
(
'
lastMessages
'
,
{
maxAge
:
600000
});
}
@
Inject
(
true
)
private
aragami
:
AragamiPlugin
;
ocrWorker
:
Worker
;
...
...
@@ -155,20 +148,23 @@ export default class HisoutensokuJammerPlugin
let
messageMatch
=
recursiveMatch
(
receivedMessage
,
matcherSingle
);
if
(
useCache
)
{
const
lastMessage
=
await
this
.
cache
.
get
(
'
lastMessages
'
,
sender
);
const
lastMessage
=
await
this
.
aragami
.
get
(
LastMessage
,
sender
);
const
currentMessage
=
receivedMessage
;
if
(
lastMessage
)
{
receivedMessage
=
`
${
lastMessage
}
${
receivedMessage
}
`
;
receivedMessage
=
`
${
lastMessage
.
message
}
${
receivedMessage
}
`
;
this
.
log
.
info
(
`Merged message from
${
sender
}
:
${
receivedMessage
}
`
);
if
(
!
messageMatch
)
{
messageMatch
=
recursiveMatch
(
receivedMessage
,
matcherSingle
);
}
}
if
(
!
messageMatch
)
{
await
this
.
cache
.
set
(
'
lastMessages
'
,
sender
,
currentMessage
);
const
message
=
new
LastMessage
();
message
.
sender
=
sender
;
message
.
message
=
currentMessage
;
await
this
.
aragami
.
set
(
message
);
return
;
}
await
this
.
cache
.
del
(
'
lastMessages
'
,
sender
);
await
this
.
aragami
.
del
(
LastMessage
,
sender
);
}
else
if
(
!
messageMatch
)
{
return
;
}
...
...
tests/sample.spec.ts
View file @
f65b1b33
import
{
App
}
from
'
koishi
'
;
import
{
Context
}
from
'
koishi
'
;
import
TargetPlugin
from
'
../src
'
;
describe
(
'
Test of plugin.
'
,
()
=>
{
let
app
:
App
;
let
app
:
Context
;
beforeEach
(
async
()
=>
{
app
=
new
App
();
app
=
new
Context
();
// app.plugin(TargetPlugin);
await
app
.
start
();
});
...
...
webpack.config.js
View file @
f65b1b33
const
path
=
require
(
'
path
'
);
const
packgeInfo
=
require
(
'
./package.json
'
);
const
{
ESBuildMinifyPlugin
}
=
require
(
'
esbuild-loader
'
);
function
externalsFromDep
()
{
return
Object
.
fromEntries
(
...
...
@@ -43,4 +44,11 @@ module.exports = {
koishi
:
'
koishi
'
,
...(
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