Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
YuzuDice
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
YuzuDice
Commits
8c3057e5
Commit
8c3057e5
authored
May 02, 2021
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix render
parent
ea6feb67
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
19 deletions
+32
-19
src/DefaultTemplate.ts
src/DefaultTemplate.ts
+15
-15
src/entities/Group.ts
src/entities/Group.ts
+2
-2
src/entities/TextTemplate.ts
src/entities/TextTemplate.ts
+2
-2
src/utility.ts
src/utility.ts
+13
-0
No files found.
src/DefaultTemplate.ts
View file @
8c3057e5
export
const
defaultTemplateMap
=
new
Map
<
string
,
string
>
();
export
const
DefaultRollText
=
'
{{
&name}} {{#reason}}因为 {{&reason}} 而{{/reason}}投掷了 {{count}} 个 {{size}} 面骰子,投掷出了 {{result}} 点。{{#formula}}
\n
{{&
formula}}{{/formula}}
'
;
'
{{
name}} {{#reason}}因为 {{reason}} 而{{/reason}}投掷了 {{count}} 个 {{size}} 面骰子,投掷出了 {{result}} 点。{{#formula}}
\n
{{
formula}}{{/formula}}
'
;
defaultTemplateMap
.
set
(
'
roll
'
,
DefaultRollText
);
export
const
DefaultRcText
=
'
{{
&name}} {{#reason}}因为 {{&reason}} 而{{/reason}}检点的结果: {{&maximumValue}}/100={{&
result}} {{#success}}成功。恭喜!{{/success}}{{^success}}失败。差一点点了,再接再厉!{{/success}}
'
;
'
{{
name}} {{#reason}}因为 {{reason}} 而{{/reason}}检点的结果: {{maximumValue}}/100={{
result}} {{#success}}成功。恭喜!{{/success}}{{^success}}失败。差一点点了,再接再厉!{{/success}}
'
;
defaultTemplateMap
.
set
(
'
rc
'
,
DefaultRcText
);
export
const
TooMuchCountText
=
'
{{
&name}} {{#reason}}因为 {{&
reason}} 而{{/reason}}投掷了 {{count}} 个 {{size}} 面骰子。
\n
骰子滚落了一地,找不到了。
'
;
'
{{
name}} {{#reason}}因为 {{
reason}} 而{{/reason}}投掷了 {{count}} 个 {{size}} 面骰子。
\n
骰子滚落了一地,找不到了。
'
;
defaultTemplateMap
.
set
(
'
too_much_count
'
,
TooMuchCountText
);
export
const
TooMuchSizeText
=
'
{{
&name}} {{#reason}}因为 {{&
reason}} 而{{/reason}}投掷了 {{count}} 个 {{size}} 面骰子。
\n
丢了个球。丢个球啊!
'
;
'
{{
name}} {{#reason}}因为 {{
reason}} 而{{/reason}}投掷了 {{count}} 个 {{size}} 面骰子。
\n
丢了个球。丢个球啊!
'
;
defaultTemplateMap
.
set
(
'
too_much_size
'
,
TooMuchSizeText
);
export
const
BadUserText
=
'
您已被禁止使用该骰娘。{{#reason}}原因是: {{
&
reason}}{{/reason}}
'
;
'
您已被禁止使用该骰娘。{{#reason}}原因是: {{reason}}{{/reason}}
'
;
defaultTemplateMap
.
set
(
'
bad_user
'
,
BadUserText
);
export
const
BadNameText
=
`你的名字 {{
&
name}} 不合法或者太长啦!`
;
export
const
BadNameText
=
`你的名字 {{name}} 不合法或者太长啦!`
;
defaultTemplateMap
.
set
(
'
bad_name
'
,
BadNameText
);
export
const
GroupNameChangedText
=
`成功修改您在本群的昵称为 {{
&
name}}。`
;
export
const
GroupNameChangedText
=
`成功修改您在本群的昵称为 {{name}}。`
;
defaultTemplateMap
.
set
(
'
group_name_changed
'
,
GroupNameChangedText
);
export
const
GlobalNameChangedText
=
`成功修改您的昵称为 {{
&
name}}。`
;
export
const
GlobalNameChangedText
=
`成功修改您的昵称为 {{name}}。`
;
defaultTemplateMap
.
set
(
'
global_name_changed
'
,
GlobalNameChangedText
);
const
banReasonText
=
'
{{#banReason}}
\n
被封禁: 是
\n
封禁原因: {{
&
banReason}}{{/banReason}}
'
;
'
{{#banReason}}
\n
被封禁: 是
\n
封禁原因: {{banReason}}{{/banReason}}
'
;
export
const
GroupUserProfileText
=
`{{
&displayUsername}}({{&user.id}}) 在群 {{&group.id}} 的资料:\n昵称: {{&
displayUsername}}
${
banReasonText
}
`
;
export
const
GroupUserProfileText
=
`{{
displayUsername}}({{user.id}}) 在群 {{group.id}} 的资料:\n昵称: {{
displayUsername}}
${
banReasonText
}
`
;
defaultTemplateMap
.
set
(
'
group_user_profile
'
,
GroupUserProfileText
);
export
const
GlobalUserProfileText
=
`{{
&name}}({{id}}) 的资料:\n昵称: {{&name}}
${
banReasonText
}
\n\n在过的群:{{#groupProfiles}}\n{{group.id}} -> {{&
name}}{{/groupProfiles}}`
;
export
const
GlobalUserProfileText
=
`{{
name}}({{id}}) 的资料:\n昵称: {{name}}
${
banReasonText
}
\n\n在过的群:{{#groupProfiles}}\n{{group.id}} -> {{
name}}{{/groupProfiles}}`
;
defaultTemplateMap
.
set
(
'
global_user_profile
'
,
GlobalUserProfileText
);
export
const
UserNotFoundText
=
`用户 {{
&
field}} 不存在。`
;
export
const
UserNotFoundText
=
`用户 {{field}} 不存在。`
;
defaultTemplateMap
.
set
(
'
user_not_found
'
,
UserNotFoundText
);
export
const
PermissionDeniedText
=
`你没有权限进行 {{
&
action}} 。`
;
export
const
PermissionDeniedText
=
`你没有权限进行 {{action}} 。`
;
defaultTemplateMap
.
set
(
'
permission_denied
'
,
PermissionDeniedText
);
export
const
BadParamsText
=
`参数不正确。`
;
...
...
@@ -50,13 +50,13 @@ defaultTemplateMap.set('bad_params', BadParamsText);
export
const
AdminQuitGroup
=
`已退出群 {{groupId}}。`
;
defaultTemplateMap
.
set
(
'
admin_quit_group
'
,
AdminQuitGroup
);
export
const
WelcomeMessageDemo
=
`本群的欢迎信息是:\n{{
&message}}\n\n示例:\n{{&
demo}}`
;
export
const
WelcomeMessageDemo
=
`本群的欢迎信息是:\n{{
message}}\n\n示例:\n{{
demo}}`
;
defaultTemplateMap
.
set
(
'
welcome_message_demo
'
,
WelcomeMessageDemo
);
export
const
WelcomeMessageNotFound
=
`本群没有设置欢迎信息。\n使用 .group.welcome <信息> 来设置一个。`
;
defaultTemplateMap
.
set
(
'
welcome_message_not_found
'
,
WelcomeMessageNotFound
);
export
const
WelcomeMessageSet
=
`已经设置群欢迎信息为 {{
&
message}}`
;
export
const
WelcomeMessageSet
=
`已经设置群欢迎信息为 {{message}}`
;
defaultTemplateMap
.
set
(
'
welcome_message_set
'
,
WelcomeMessageSet
);
export
const
GroupAllowSet
=
`已经设置群 {{groupId}} 可加入状态为 {{value}}。`
;
...
...
src/entities/Group.ts
View file @
8c3057e5
...
...
@@ -4,7 +4,7 @@ import { GroupTemplate } from './GroupTemplate';
import
{
GroupUserProfile
}
from
'
./GroupUserProfile
'
;
import
he
from
'
he
'
;
import
{
User
}
from
'
./User
'
;
import
Mustache
from
'
mustache
'
;
import
{
Utility
}
from
'
../utility
'
;
@
Entity
()
export
class
Group
extends
QQIDBase
{
...
...
@@ -32,7 +32,7 @@ export class Group extends QQIDBase {
if
(
!
this
.
welcomeMessage
)
{
return
null
;
}
return
Mustache
.
render
(
this
.
welcomeMessage
,
user
);
return
Utility
.
render
(
this
.
welcomeMessage
,
user
);
}
renderText
(
key
:
string
,
data
:
any
)
{
...
...
src/entities/TextTemplate.ts
View file @
8c3057e5
import
{
TimeBase
}
from
'
./TimeBase
'
;
import
{
Column
,
PrimaryGeneratedColumn
}
from
'
typeorm
'
;
import
Mustache
from
'
mustache
'
;
import
{
decode
}
from
'
he
'
;
import
{
Utility
}
from
'
../utility
'
;
export
class
TextTemplate
extends
TimeBase
{
key
:
string
;
// column differs
...
...
@@ -19,7 +19,7 @@ export class TextTemplate extends TimeBase {
}
render
(
data
:
any
)
{
return
Mustache
.
render
(
this
.
getContent
(),
data
);
return
Utility
.
render
(
this
.
getContent
(),
data
);
}
display
()
{
...
...
src/utility.ts
0 → 100644
View file @
8c3057e5
import
Mustache
from
'
mustache
'
;
export
class
Utility
{
static
render
(
template
:
string
,
view
:
any
):
string
{
try
{
return
Mustache
.
render
(
template
,
view
,
null
,
{
escape
:
(
value
)
=>
value
,
});
}
catch
(
e
)
{
return
`模板错误:
${
JSON
.
stringify
(
view
)}
${
e
.
toString
()}
`
;
}
}
}
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