Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
N
nil2bot
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to JiHu GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Iori Ichinose
nil2bot
Commits
d3d031f4
Commit
d3d031f4
authored
3 years ago
by
Iori Ichinose
Browse files
Options
Downloads
Patches
Plain Diff
update choosing songs
parent
48e30fc6
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/plugins/ask/data_resource.py
+6
-0
6 additions, 0 deletions
src/plugins/ask/data_resource.py
src/plugins/ask/parse_question.py
+6
-1
6 additions, 1 deletion
src/plugins/ask/parse_question.py
with
12 additions
and
1 deletion
src/plugins/ask/data_resource.py
+
6
−
0
View file @
d3d031f4
from
data.ask
import
*
import
re
import
json
ARC_PATH
=
'
./data/arc_titles.json
'
LUCK_LEN
=
(
len
(
luck
[
'
rank
'
]),
len
(
luck
[
'
event
'
]))
# jokes = ...
jokes
=
[
'
TODO
'
]
poet_re
=
re
.
compile
(
r
'
\[CQ:at,qq=(\d+)\]
'
)
with
open
(
ARC_PATH
,
'
r
'
)
as
f
:
arc
:
dict
[
dict
[
str
,
str
]]
=
json
.
load
(
f
)
titles
=
sum
((
list
(
title
.
values
())
for
title
in
(
title
for
title
in
arc
.
values
())),
[])
This diff is collapsed.
Click to expand it.
src/plugins/ask/parse_question.py
+
6
−
1
View file @
d3d031f4
...
...
@@ -23,10 +23,11 @@ class Type(Enum):
OR_NO1
=
8
OR_NO2
=
9
OR_NOT
=
10
ARC
=
11
tokens
=
{
re
.
compile
(
r
'
什么时候
'
):
Type
.
TIME
,
re
.
compile
(
r
'
什么歌
'
):
Type
.
ARC
,
re
.
compile
(
r
'
多少
'
):
Type
.
R100
,
re
.
compile
(
r
'
谁
'
):
Type
.
NAME
,
re
.
compile
(
r
'
为什么
'
):
Type
.
REASON
,
...
...
@@ -104,6 +105,9 @@ class Parser:
def
choose_not
(
self
,
token
:
str
)
->
str
:
return
random
.
choice
([
'
没
'
,
''
])
+
token
[
0
]
def
arc
(
self
,
token
:
str
)
->
str
:
return
random
.
choice
(
titles
)
def
normal
(
self
,
token
:
str
)
->
str
:
return
token
...
...
@@ -120,6 +124,7 @@ class Parser:
Type
.
OR_NO1
:
choose_no1
,
Type
.
OR_NO2
:
choose_no2
,
Type
.
OR_NOT
:
choose_not
,
Type
.
ARC
:
arc
,
Type
.
NORMAL
:
normal
,
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment