Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
J
Jdaw
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
MyCard
Jdaw
Commits
f2ae1693
Commit
f2ae1693
authored
Jan 12, 2023
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix accident command click
parent
cc711e8a
Pipeline
#19432
canceled with stages
in 7 minutes and 59 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
59 additions
and
0 deletions
+59
-0
src/app.module.ts
src/app.module.ts
+2
-0
src/bot/bot.service.spec.ts
src/bot/bot.service.spec.ts
+18
-0
src/bot/bot.service.ts
src/bot/bot.service.ts
+28
-0
src/feedback/feedback.service.ts
src/feedback/feedback.service.ts
+11
-0
No files found.
src/app.module.ts
View file @
f2ae1693
...
...
@@ -15,6 +15,7 @@ import PuppeteerPlugin from 'koishi-plugin-puppeteer';
import
{
HttpModule
}
from
'
@nestjs/axios
'
;
import
{
Feedback
}
from
'
./feedback/entities/feedback.entity
'
;
import
{
OnSubscribeService
}
from
'
./on-subscribe/on-subscribe.service
'
;
import
{
BotService
}
from
'
./bot/bot.service
'
;
@
Module
({
imports
:
[
...
...
@@ -153,6 +154,7 @@ import { OnSubscribeService } from './on-subscribe/on-subscribe.service';
CdbLoaderService
,
FeedbackService
,
OnSubscribeService
,
BotService
,
],
})
export
class
AppModule
{}
src/bot/bot.service.spec.ts
0 → 100644
View file @
f2ae1693
import
{
Test
,
TestingModule
}
from
'
@nestjs/testing
'
;
import
{
BotService
}
from
'
./bot.service
'
;
describe
(
'
BotService
'
,
()
=>
{
let
service
:
BotService
;
beforeEach
(
async
()
=>
{
const
module
:
TestingModule
=
await
Test
.
createTestingModule
({
providers
:
[
BotService
],
}).
compile
();
service
=
module
.
get
<
BotService
>
(
BotService
);
});
it
(
'
should be defined
'
,
()
=>
{
expect
(
service
).
toBeDefined
();
});
});
src/bot/bot.service.ts
0 → 100644
View file @
f2ae1693
import
{
Injectable
,
OnApplicationBootstrap
}
from
'
@nestjs/common
'
;
import
{
WireContextService
}
from
'
koishi-nestjs
'
;
import
WechatBot
from
'
koishi-plugin-adapter-wechat-official
'
;
@
Injectable
()
export
class
BotService
implements
OnApplicationBootstrap
{
@
WireContextService
()
private
bots
:
WechatBot
[];
getBot
()
{
return
this
.
bots
[
0
];
}
private
builtinCommands
=
new
Set
<
string
>
();
onApplicationBootstrap
()
{
this
.
getBot
()
.
config
.
menus
.
flatMap
((
menu
)
=>
menu
.
children
.
map
((
child
)
=>
child
.
command
),
)
.
filter
((
command
)
=>
command
)
.
forEach
((
command
)
=>
this
.
builtinCommands
.
add
(
command
));
}
isBuiltinCommand
(
command
:
string
)
{
return
this
.
builtinCommands
.
has
(
command
);
}
}
src/feedback/feedback.service.ts
View file @
f2ae1693
...
...
@@ -12,6 +12,7 @@ import { Random, Session } from 'koishi';
import
{
HttpService
}
from
'
@nestjs/axios
'
;
import
{
lastValueFrom
}
from
'
rxjs
'
;
import
{
PutSession
,
UseCommand
}
from
'
koishi-nestjs
'
;
import
{
BotService
}
from
'
../bot/bot.service
'
;
@
Injectable
()
export
class
FeedbackService
extends
CrudService
(
Feedback
)
{
...
...
@@ -22,6 +23,7 @@ export class FeedbackService extends CrudService(Feedback) {
@
InjectRepository
(
Feedback
)
repo
:
Repository
<
Feedback
>
,
private
config
:
ConfigService
,
private
http
:
HttpService
,
private
botService
:
BotService
,
)
{
super
(
repo
);
}
...
...
@@ -88,6 +90,9 @@ export class FeedbackService extends CrudService(Feedback) {
let
choice
=
0
;
while
(
true
)
{
const
input
=
await
session
.
prompt
();
if
(
this
.
botService
.
isBuiltinCommand
(
input
))
{
return
session
.
execute
(
input
);
}
choice
=
parseInt
(
input
.
trim
());
if
(
choice
>=
1
&&
choice
<=
4
)
{
break
;
...
...
@@ -104,6 +109,9 @@ export class FeedbackService extends CrudService(Feedback) {
const
category
=
[
'
游戏功能/改善
'
,
'
游戏体验问题
'
,
'
其他
'
][
choice
-
2
];
await
session
.
send
(
'
您启动了反馈系统!您的下一段文字会作为反馈发给我们!
'
);
const
content
=
await
session
.
prompt
();
if
(
this
.
botService
.
isBuiltinCommand
(
content
))
{
return
session
.
execute
(
content
);
}
const
count
=
await
this
.
createFeedback
(
session
,
{
category
,
content
});
return
`反馈成功!谢谢您的意见!
这是我们在决斗暗网服务号收到的第
${
count
}
个反馈!`
;
...
...
@@ -118,6 +126,9 @@ export class FeedbackService extends CrudService(Feedback) {
'
为此,希望您可以尽可能清晰表达您的意见,以便我们更好理解您的需求。
'
,
);
const
content
=
await
session
.
prompt
();
if
(
this
.
botService
.
isBuiltinCommand
(
content
))
{
return
session
.
execute
(
content
);
}
const
count
=
await
this
.
createFeedback
(
session
,
{
category
:
'
周边
'
,
content
,
...
...
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