2023-07-24 22:44:06 +03:00
|
|
|
/- settings
|
2023-07-14 19:08:16 +03:00
|
|
|
/+ summarize, default-agent, verb, dbug
|
2023-04-17 18:18:41 +03:00
|
|
|
::
|
|
|
|
|%
|
|
|
|
+$ card card:agent:gall
|
2023-10-04 11:55:20 +03:00
|
|
|
+$ state-1 [%1 enabled=_| bark-host=_~rilfet-palsum]
|
2023-04-17 18:18:41 +03:00
|
|
|
--
|
|
|
|
::
|
|
|
|
:: This agent should eventually go into landscape
|
|
|
|
::
|
2023-10-04 11:55:20 +03:00
|
|
|
=| state-1
|
2023-04-17 18:18:41 +03:00
|
|
|
=* state -
|
|
|
|
%- agent:dbug
|
|
|
|
%+ verb |
|
|
|
|
^- agent:gall
|
|
|
|
|_ =bowl:gall
|
|
|
|
+* this .
|
|
|
|
def ~(. (default-agent this %.n) bowl)
|
2023-07-21 19:42:51 +03:00
|
|
|
::
|
2023-04-17 18:18:41 +03:00
|
|
|
++ on-init
|
2023-10-06 21:29:54 +03:00
|
|
|
=^ caz this (on-poke %initialize !>(~))
|
2023-10-06 21:20:05 +03:00
|
|
|
:_ this
|
|
|
|
::NOTE sadly, we cannot subscribe to items that may not exist right now,
|
|
|
|
:: so we subscribe to the whole bucket instead
|
|
|
|
[[%pass /settings %agent [our.bowl %settings] %watch /desk/groups] caz]
|
2023-07-21 19:42:51 +03:00
|
|
|
::
|
2023-10-04 11:55:20 +03:00
|
|
|
++ on-save !>(state)
|
|
|
|
++ on-load
|
|
|
|
|= old-state=vase
|
|
|
|
|^ ^- (quip card _this)
|
|
|
|
=+ !<(old=versioned-state old-state)
|
|
|
|
?- -.old
|
2023-10-06 21:20:05 +03:00
|
|
|
:: %0 lost sync with the flag so must re-set, but not scry during load
|
|
|
|
::
|
|
|
|
%0 [[%pass /re-set %arvo %b %wait now.bowl]~ this]
|
|
|
|
%1 [~ this(state old)]
|
2023-10-04 11:55:20 +03:00
|
|
|
==
|
|
|
|
::
|
|
|
|
+$ versioned-state $%(state-0 state-1)
|
|
|
|
+$ state-0 [%0 enabled=_| bark-host=_~rilfet-palsum]
|
|
|
|
--
|
|
|
|
::
|
2023-04-17 18:18:41 +03:00
|
|
|
++ on-poke
|
|
|
|
|= [=mark =vase]
|
|
|
|
^- (quip card _this)
|
|
|
|
?+ mark (on-poke:def mark vase)
|
2023-07-19 21:23:39 +03:00
|
|
|
%noun
|
|
|
|
=+ !<([m=@ n=*] vase)
|
|
|
|
$(mark m, vase (need (slew 3 vase)))
|
|
|
|
::
|
2023-04-25 01:41:14 +03:00
|
|
|
%set-host
|
|
|
|
?> =(src.bowl our.bowl)
|
|
|
|
`this(bark-host !<(ship vase))
|
2023-10-06 21:20:05 +03:00
|
|
|
::
|
2023-10-06 21:29:54 +03:00
|
|
|
%initialize
|
2023-10-06 21:20:05 +03:00
|
|
|
=; consent=?
|
|
|
|
$(mark ?:(consent %enable %disable), vase !>(~))
|
|
|
|
=/ bap=path /(scot %p our.bowl)/settings/(scot %da now.bowl)
|
|
|
|
?. .^(? %gu (snoc bap %$)) |
|
|
|
|
=+ .^(=data:settings %gx (weld bap /desk/groups/settings-data))
|
|
|
|
?> ?=(%desk -.data)
|
|
|
|
=; =val:settings
|
|
|
|
?:(?=(%b -.val) p.val |)
|
|
|
|
%+ %~ gut by
|
|
|
|
(~(gut by desk.data) %groups ~)
|
|
|
|
'logActivity'
|
|
|
|
[%b |]
|
|
|
|
::
|
2023-04-17 18:18:41 +03:00
|
|
|
%enable
|
2023-04-25 01:41:14 +03:00
|
|
|
:_ this(enabled %.y)
|
|
|
|
~[[%pass /add-recipient %agent [bark-host %bark] %poke %bark-add-recipient !>(our.bowl)]]
|
2023-10-06 21:20:05 +03:00
|
|
|
::
|
2023-04-17 18:18:41 +03:00
|
|
|
%disable
|
2023-04-25 01:41:14 +03:00
|
|
|
:_ this(enabled %.n)
|
|
|
|
~[[%pass /remove-recipient %agent [bark-host %bark] %poke %bark-remove-recipient !>(our.bowl)]]
|
2023-10-06 21:20:05 +03:00
|
|
|
::
|
2023-04-25 01:41:14 +03:00
|
|
|
%growl-summarize
|
|
|
|
?. enabled
|
2023-04-17 18:18:41 +03:00
|
|
|
:_ this
|
2023-04-25 01:41:14 +03:00
|
|
|
~[[%pass /bark-summary %agent [bark-host %bark] %poke %bark-receive-summary !>(~)]]
|
|
|
|
=/ requested !<(time vase)
|
2023-07-14 19:08:16 +03:00
|
|
|
=/ activity ~(summarize-activity summarize [our now]:bowl)
|
|
|
|
=/ inactivity ~(summarize-inactivity summarize [our now]:bowl)
|
2023-04-25 01:41:14 +03:00
|
|
|
:_ this
|
2023-07-14 19:08:16 +03:00
|
|
|
~[[%pass /bark-summary %agent [bark-host %bark] %poke %bark-receive-summary !>(`[requested %life activity inactivity])]]
|
2023-04-17 18:18:41 +03:00
|
|
|
==
|
2023-07-21 19:42:51 +03:00
|
|
|
::
|
|
|
|
++ on-agent
|
|
|
|
|= [=wire =sign:agent:gall]
|
|
|
|
^- (quip card _this)
|
|
|
|
?. ?=([%settings ~] wire) (on-agent:def wire sign)
|
|
|
|
?- -.sign
|
|
|
|
%poke-ack !!
|
|
|
|
::
|
|
|
|
%watch-ack
|
|
|
|
?~ p.sign [~ this]
|
|
|
|
%- (slog 'growl failed settings subscription' u.p.sign)
|
|
|
|
[~ this]
|
|
|
|
::
|
|
|
|
%kick
|
|
|
|
[[%pass /settings %agent [our.bowl %settings] %watch /desk/groups]~ this]
|
|
|
|
::
|
|
|
|
%fact
|
|
|
|
?. =(%settings-event p.cage.sign) (on-agent:def wire sign)
|
|
|
|
=+ !<(=event:settings q.cage.sign)
|
2023-10-04 11:55:20 +03:00
|
|
|
=/ new=(unit ?)
|
|
|
|
=; val=(unit val:settings)
|
|
|
|
?~ val ~
|
|
|
|
`?:(?=(%b -.u.val) p.u.val |)
|
|
|
|
?+ event ~
|
|
|
|
[%put-bucket %groups %groups *] `(~(gut by bucket.event) 'logActivity' b+|)
|
|
|
|
[%del-bucket %groups %groups] `b+|
|
|
|
|
[%put-entry %groups %groups %'logActivity' *] `val.event
|
|
|
|
[%del-entry %groups %groups %'logActivity'] `b+|
|
2023-07-21 19:42:51 +03:00
|
|
|
==
|
2023-10-04 11:55:20 +03:00
|
|
|
?~ new [~ this]
|
|
|
|
?: =(u.new enabled) [~ this]
|
|
|
|
(on-poke ?:(u.new %enable %disable) !>(~))
|
2023-07-21 19:42:51 +03:00
|
|
|
==
|
|
|
|
::
|
2023-10-06 21:20:05 +03:00
|
|
|
++ on-arvo
|
|
|
|
|= [=wire sign=sign-arvo]
|
|
|
|
^- (quip card _this)
|
|
|
|
?> =(/re-set wire)
|
|
|
|
?> ?=(%wake +<.sign)
|
2023-10-06 21:29:54 +03:00
|
|
|
(on-poke %initialize !>(~))
|
2023-10-06 21:20:05 +03:00
|
|
|
::
|
2023-04-25 01:41:14 +03:00
|
|
|
++ on-watch on-watch:def
|
2023-04-17 18:18:41 +03:00
|
|
|
++ on-fail
|
|
|
|
|= [=term =tang]
|
|
|
|
(mean ':sub +on-fail' term tang)
|
|
|
|
++ on-leave
|
|
|
|
|= =path
|
|
|
|
`this
|
|
|
|
++ on-peek on-peek:def
|
|
|
|
--
|