mirror of
https://github.com/AynaLivePlayer/AynaLivePlayer.git
synced 2025-12-17 07:28:20 +08:00
local search algorithm optimization/diange medal permission/
This commit is contained in:
@@ -25,5 +25,6 @@ func main() {
|
||||
controller.ClosePlugins(plugins...)
|
||||
controller.Destroy()
|
||||
_ = config.SaveToConfigFile(config.ConfigPath)
|
||||
//i18n.SaveTranslation()
|
||||
logger.Logger.Info("================Program End================")
|
||||
}
|
||||
|
||||
@@ -224,6 +224,18 @@
|
||||
"en": "Basic Diange Configuration",
|
||||
"zh-CN": "点歌基本设置"
|
||||
},
|
||||
"plugin.diange.medal.level": {
|
||||
"en": "Level",
|
||||
"zh-CN": "等级"
|
||||
},
|
||||
"plugin.diange.medal.name": {
|
||||
"en": "Name",
|
||||
"zh-CN": "牌子名"
|
||||
},
|
||||
"plugin.diange.medal.perm": {
|
||||
"en": "Medal Permission",
|
||||
"zh-CN": "牌子点歌权限"
|
||||
},
|
||||
"plugin.diange.permission": {
|
||||
"en": "Permission",
|
||||
"zh-CN": "点歌权限"
|
||||
@@ -348,6 +360,10 @@
|
||||
"en": "Stop",
|
||||
"zh-CN": "停止"
|
||||
},
|
||||
"plugin.webinfo.server_preview": {
|
||||
"en": "Server Preview",
|
||||
"zh-CN": "效果预览"
|
||||
},
|
||||
"plugin.webinfo.server_status": {
|
||||
"en": "Server Status",
|
||||
"zh-CN": "服务器状态"
|
||||
@@ -363,10 +379,6 @@
|
||||
"plugin.webinfo.title": {
|
||||
"en": "Web Output",
|
||||
"zh-CN": "Web输出"
|
||||
},
|
||||
"plugin.webinfo.server_preview": {
|
||||
"en": "Server Preview",
|
||||
"zh-CN":"效果预览"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,8 @@ type Diange struct {
|
||||
UserPermission bool
|
||||
PrivilegePermission bool
|
||||
AdminPermission bool
|
||||
MedalName string
|
||||
MedalPermission int
|
||||
QueueMax int
|
||||
UserCoolDown int
|
||||
CustomCMD string
|
||||
@@ -117,6 +119,10 @@ func (d *Diange) Execute(command string, args []string, danmu *liveclient.DanmuM
|
||||
l().Trace("privilege permission check: ", perm)
|
||||
perm = perm || (d.AdminPermission && (danmu.User.Admin))
|
||||
l().Trace("admin permission check: ", perm)
|
||||
// if use medal check
|
||||
if d.MedalName != "" && d.MedalPermission >= 0 {
|
||||
perm = perm || ((danmu.User.Medal.Name == d.MedalName) && danmu.User.Medal.Level >= d.MedalPermission)
|
||||
}
|
||||
if !perm {
|
||||
return
|
||||
}
|
||||
@@ -147,6 +153,17 @@ func (d *Diange) CreatePanel() fyne.CanvasObject {
|
||||
widget.NewCheckWithData(i18n.T("plugin.diange.privilege"), binding.BindBool(&d.PrivilegePermission)),
|
||||
widget.NewCheckWithData(i18n.T("plugin.diange.admin"), binding.BindBool(&d.AdminPermission)),
|
||||
)
|
||||
dgMdPerm := container.NewBorder(nil, nil,
|
||||
widget.NewLabel(i18n.T("plugin.diange.medal.perm")), nil,
|
||||
container.NewGridWithColumns(2,
|
||||
container.NewBorder(nil, nil,
|
||||
widget.NewLabel(i18n.T("plugin.diange.medal.name")), nil,
|
||||
widget.NewEntryWithData(binding.BindString(&d.MedalName))),
|
||||
container.NewBorder(nil, nil,
|
||||
widget.NewLabel(i18n.T("plugin.diange.medal.level")), nil,
|
||||
widget.NewEntryWithData(binding.IntToString(binding.BindInt(&d.MedalPermission)))),
|
||||
),
|
||||
)
|
||||
dgQueue := container.NewBorder(nil, nil,
|
||||
widget.NewLabel(i18n.T("plugin.diange.queue_max")), nil,
|
||||
widget.NewEntryWithData(binding.IntToString(binding.BindInt(&d.QueueMax))),
|
||||
@@ -170,6 +187,6 @@ func (d *Diange) CreatePanel() fyne.CanvasObject {
|
||||
dgSourceCMD := container.NewBorder(
|
||||
nil, nil, widget.NewLabel(i18n.T("plugin.diange.source_cmd")), nil,
|
||||
container.NewVBox(sourceCmds...))
|
||||
d.panel = container.NewVBox(dgPerm, dgQueue, dgCoolDown, dgShortCut, dgSourceCMD)
|
||||
d.panel = container.NewVBox(dgPerm, dgMdPerm, dgQueue, dgCoolDown, dgShortCut, dgSourceCMD)
|
||||
return d.panel
|
||||
}
|
||||
|
||||
@@ -80,13 +80,16 @@ func (l *Local) Search(keyword string) ([]*player.Media, error) {
|
||||
keywords := strings.Split(keyword, " ")
|
||||
for _, p := range l.Playlists {
|
||||
for _, m := range p.Medias {
|
||||
title := strings.ToLower(m.Title)
|
||||
artist := strings.ToLower(m.Artist)
|
||||
n := 0
|
||||
for _, k := range keywords {
|
||||
if strings.Contains(m.Title, k) || strings.Contains(m.Artist, k) {
|
||||
kw := strings.ToLower(k)
|
||||
if strings.Contains(title, kw) || strings.Contains(artist, kw) {
|
||||
n++
|
||||
}
|
||||
if k == m.Title {
|
||||
n += 2
|
||||
if kw == title {
|
||||
n += 3
|
||||
}
|
||||
}
|
||||
if n > 0 {
|
||||
|
||||
Reference in New Issue
Block a user