From 5d8cfa91380d1645872c71842082904d9961cc50 Mon Sep 17 00:00:00 2001 From: shy Date: Sun, 21 Jan 2024 10:08:12 +0800 Subject: [PATCH] add chat.script --- core/chat/footer.go | 3 +++ core/chat/script.go | 22 ++++++++++++++++++++++ core/chat/script.js | 19 +++++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 core/chat/script.go create mode 100644 core/chat/script.js diff --git a/core/chat/footer.go b/core/chat/footer.go index 7d38cce6..da260aef 100644 --- a/core/chat/footer.go +++ b/core/chat/footer.go @@ -31,6 +31,9 @@ func init() { return nfs.SplitPath(m, ctx.GetCmdFile(m, arg[0])) }, arg...) }}, + nfs.SCRIPT: {Hand: func(m *ice.Message, arg ...string) { + m.Cmd(SCRIPT, mdb.INSERT, mdb.ZONE, "default", ctx.INDEX, arg[0], ice.AUTO, arg[2]) + }}, ctx.CONFIG: {Hand: func(m *ice.Message, arg ...string) { _footer_plugin(m, ctx.CONFIG, arg, arg...) }}, diff --git a/core/chat/script.go b/core/chat/script.go new file mode 100644 index 00000000..31182b47 --- /dev/null +++ b/core/chat/script.go @@ -0,0 +1,22 @@ +package chat + +import ( + ice "shylinux.com/x/icebergs" + "shylinux.com/x/icebergs/base/mdb" +) + +const SCRIPT = "script" + +func init() { + Index.MergeCommands(ice.Commands{ + SCRIPT: {Name: "script zone id auto", Help: "脚本", Actions: ice.MergeActions(mdb.ZoneAction(mdb.FIELDS, "time,index,auto")), Hand: func(m *ice.Message, arg ...string) { + mdb.ZoneSelect(m, arg...) + m.Display("") + if len(arg) == 0 { + m.PushAction("play", mdb.REMOVE) + } else { + m.Action("play") + } + }}, + }) +} diff --git a/core/chat/script.js b/core/chat/script.js new file mode 100644 index 00000000..36ba5b4d --- /dev/null +++ b/core/chat/script.js @@ -0,0 +1,19 @@ +Volcanos(chat.ONIMPORT, { + _init: function(can, msg) { + can.onappend.table(can, msg) + can.onappend.board(can, msg) + }, +}) +Volcanos(chat.ONACTION, { + play: function(event, can) { + can.core.Next(can._msg.Table(), function(value, next) { + var done = false + can.onappend.plugin(can, {index: value.index}, function(sub) { + can.onmotion.delay(can, function() { + if (!sub._auto) { sub.Update({}, [ctx.ACTION, value.auto], function() { next() }) } + }, 300) + sub.onexport.output = function() { done || sub.Update({}, [ctx.ACTION, value.auto], function() { next() }), done = true } + }) + }) + }, +})