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
b248c4a8
Commit
b248c4a8
authored
Mar 04, 2022
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add message log
parent
d7cad63e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
18 deletions
+28
-18
src/index.ts
src/index.ts
+28
-18
No files found.
src/index.ts
View file @
b248c4a8
import
'
source-map-support/register
'
;
import
{
Context
,
Logger
,
Next
,
Session
,
Cache
,
segment
}
from
'
koishi
'
;
import
{
HisoutensokuJammerPluginConfig
,
HisoutensokuJammerPluginConfigLike
,
}
from
'
./config
'
;
import
{
Logger
,
Next
,
Session
,
Cache
,
segment
}
from
'
koishi
'
;
import
{
HisoutensokuJammerPluginConfig
}
from
'
./config
'
;
import
{
DefinePlugin
,
InjectConfig
,
UseMiddleware
,
InjectLogger
,
Inject
,
UseEvent
,
OnApply
,
BasePlugin
,
}
from
'
koishi-thirdeye
'
;
import
{
Attacker
}
from
'
./attacker
'
;
import
moment
from
'
moment
'
;
import
{
chineseCharacterList
}
from
'
./chinese-replace
'
;
import
{
createWorker
,
Worker
}
from
'
tesseract.js
'
;
import
{
Worker
}
from
'
tesseract.js
'
;
import
_
from
'
lodash
'
;
export
*
from
'
./config
'
;
declare
module
'
koishi
'
{
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace
Cache
{
interface
Tables
{
lastMessages
:
string
;
...
...
@@ -38,12 +37,10 @@ const PROTOCOL_BASE64 = 'base64://';
name
:
'
hisoutensoku-jammer
'
,
schema
:
HisoutensokuJammerPluginConfig
,
})
export
default
class
HisoutensokuJammerPlugin
implements
OnApply
{
constructor
(
private
ctx
:
Context
,
config
:
HisoutensokuJammerPluginConfigLike
,
)
{}
export
default
class
HisoutensokuJammerPlugin
extends
BasePlugin
<
HisoutensokuJammerPluginConfig
>
implements
OnApply
{
@
InjectLogger
()
private
log
:
Logger
;
...
...
@@ -54,9 +51,6 @@ export default class HisoutensokuJammerPlugin implements OnApply {
this
.
cache
.
table
(
'
lastMessages
'
,
{
maxAge
:
600000
});
}
@
InjectConfig
()
private
config
:
HisoutensokuJammerPluginConfig
;
ocrWorker
:
Worker
;
@
UseEvent
(
'
ready
'
)
...
...
@@ -138,12 +132,15 @@ export default class HisoutensokuJammerPlugin implements OnApply {
);
}
this
.
log
.
info
(
`Parsing message from
${
sender
}
:
${
receivedMessage
}
`
);
let
messageMatch
=
receivedMessage
.
match
(
matcherGlobal
);
if
(
useCache
)
{
const
lastMessage
=
await
this
.
cache
.
get
(
'
lastMessages
'
,
sender
);
const
currentMessage
=
receivedMessage
;
if
(
lastMessage
)
{
receivedMessage
=
`
${
lastMessage
}
${
receivedMessage
}
`
;
this
.
log
.
info
(
`Merged message from
${
sender
}
:
${
receivedMessage
}
`
);
if
(
!
messageMatch
)
{
messageMatch
=
receivedMessage
.
match
(
matcherGlobal
);
}
...
...
@@ -159,6 +156,9 @@ export default class HisoutensokuJammerPlugin implements OnApply {
const
results
:
{
address
:
string
;
port
:
number
}[]
=
[];
for
(
const
pattern
of
messageMatch
)
{
const
patternMatch
=
pattern
.
match
(
matcherSingle
);
if
((
patternMatch
?.
length
||
0
)
<=
6
)
{
continue
;
}
const
firstDigit
=
patternMatch
[
2
].
replace
(
/
[^\d]
+/g
,
''
);
const
address
=
`
${
firstDigit
}
.
${
patternMatch
[
3
]
.
split
(
/
[^\d]
+/
)
...
...
@@ -179,7 +179,17 @@ export default class HisoutensokuJammerPlugin implements OnApply {
}
}
}
return
results
;
const
filteredResults
=
_
.
uniqWith
(
results
,
(
a
,
b
)
=>
a
.
address
===
b
.
address
&&
a
.
port
===
b
.
port
,
);
this
.
log
.
info
(
`Got addresses:
${
filteredResults
.
map
((
e
)
=>
`
${
e
.
address
}
:
${
e
.
port
}
`
)
.
join
(
'
,
'
)}
.`
,
);
return
filteredResults
;
}
private
async
handleMessage
(
...
...
@@ -188,7 +198,7 @@ export default class HisoutensokuJammerPlugin implements OnApply {
useCache
=
true
,
)
{
const
targets
=
await
this
.
getTargetsFromMessage
(
message
,
sender
,
useCache
);
if
(
!
targets
)
return
;
if
(
!
targets
?.
length
)
return
;
const
results
:
boolean
[]
=
await
Promise
.
all
(
targets
.
map
((
target
)
=>
{
return
this
.
startAttack
(
target
.
address
,
target
.
port
);
...
...
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