Merge remote-tracking branches 'ohaitch/pojo-cen-s-tco', 'ohaitch/easter-egg' and 'ohaitch/ap-abut-bad-bone'

Optimize ++pojo
Add :ask and |ask
Survive filling bad bones
This commit is contained in:
Raymond Pasco 2015-11-27 11:47:58 -05:00
commit f800913504
8 changed files with 125 additions and 25 deletions

58
ape/ask.hoon Normal file
View File

@ -0,0 +1,58 @@
:: There is no love that is not an echo
::
:::: /hoon/echo/ape
::
/? 314
/+ sole
[. sole]
|%
++ card
$% [%diff %sole-effect sole-effect]
==
--
!:
|_ [bow=bowl adr=(set cord) sos=(map bone sole-share)]
++ peer-sole
|= path
^- (quip ,[bone card] +>)
~| [%not-in-whitelist src.bow]
?> (~(has in (sa (limo ~zod our.bow ~talsur-todres ~))) src.bow)
:_ +>.$(sos (~(put by sos) ost.bow *sole-share))
=- [(effect %mor pro/[& %$ "<listening>"] -)]~
=+ all=adrs
[tan/(turn all message) (turn all put-mail)]
::
++ adrs (sort (~(tap by adr)) aor)
++ effect |=(fec=sole-effect [ost.bow %diff %sole-effect fec])
++ message |=(ask=@t leaf/"ask: {(trip ask)}")
++ put-mail |=(ask=@t =+(pax=(rash ask unix-path) [%sav pax '']))
++ unix-path :: split into path of "name" and "extension"
;~ (glue dot)
(cook crip (star ;~(less dot next)))
;~(plug (cook crip (star next)) (easy ~))
==
::
++ poke-ask-mail
|= ask=@t
^- (quip ,[bone card] +>)
~| have-mail/ask
?< (~(has in adr) ask)
:_ +>.$(adr (~(put in adr) ask))
=+ [mez=[(message ask)]~ sav=(put-mail ask)]
%+ turn (prey /sole bow)
|=([ost=bone ^] (effect(ost.bow ost) %mor tan/mez sav ~))
::
++ poke-sole-action
|= act=sole-action
^- (quip ,[bone card] +>)
?- -.act
%clr `+>.$
%ret [[(effect tan/(turn adrs message))]~ +>.$] :: re-print list
%det :: reject all input
=+ som=(~(got by sos) ost.bow) :: XX this code belongs in a library
=^ inv som (~(transceive sole som) +.act)
=^ det som (~(transmit sole som) inv)
=. sos (~(put by sos) ost.bow som)
[[(effect det/det)]~ +>.$]
==
--

View File

@ -10,7 +10,8 @@
!: :: ::
=> |% :: external structures
++ house :: all state
$: %3
$: %4
egg=@u :: command count
hoc=(map bone session) :: conversations
== ::
++ session :: per conversation
@ -161,7 +162,7 @@
++ dp-sink
;~ pose
;~(plug (cold %file tar) dp-beam)
;~(plug (cold %flat pat) (most fas sym))
;~(plug (cold %flat pat) (most fas qut))
;~(plug (cold %pill dot) (most fas sym))
;~(plug (cold %http lus) (easy %post) auri:epur)
;~(plug (cold %http hep) (easy %put) auri:epur)
@ -734,9 +735,9 @@
^+ +>+>
?> ?=(~ cud)
?: ?=([%show 3] -.mad)
dy-over
he-easter:dy-over
?: =(nex num)
dy-over
he-easter:dy-over
dy-make(cud `[nex (~(got by job) nex)])
--
::
@ -761,6 +762,16 @@
%& [%& p.foy]
==
::
++ he-easter :: hint messages
^+ .
=. egg +(egg)
=- ?~(msg ..he-diff (he-diff %tan leaf/u.msg ~))
^- msg=(unit tape)
?+ (clan our.hid) ~
%pawn ?+ egg ~
5 `":: To request a planet, run |ask 'your@email.co'"
== ==
::
++ he-abet :: resolve
[(flop moz) %_(+> hoc (~(put by hoc) ost.hid +<+))]
::
@ -946,13 +957,15 @@
$% [%0 p=(map bone session-0)]
[%1 p=(map bone session-1)]
[%2 p=(map bone session-1)]
[%3 p=(map bone session)]
==
|= old=(unit ?(house hoze)) ^+ [~ ..prep]
?~ old `..prep
?- -.u.old
%3 `..prep(+<+ u.old)
%2 `..prep(+<+ [%3 (~(run by p.u.old) |=(session-1 +<(poy ~)))])
%1 `..prep(+<+ [%3 (~(run by p.u.old) |=(session-1 +<(poy ~)))])
%4 `..prep(+<+ u.old)
%3 $(u.old %*(. *house hoc p.u.old))
%2 $(u.old [%3 (~(run by p.u.old) |=(session-1 +<(poy ~)))])
%1 $(u.old [%3 (~(run by p.u.old) |=(session-1 +<(poy ~)))])
%0 =< ^$(u.old [%1 (~(run by p.u.old) .)])
|= sos=session-0 ^- session-1
[-.sos [[our.hid syd.sos ud/0] /] |3.sos]

View File

@ -103,6 +103,7 @@
++ poke-helm-reload-desk (wrap poke-reload-desk):from-helm
++ poke-helm-reset (wrap poke-reset):from-helm
++ poke-helm-send-hi (wrap poke-send-hi):from-helm
++ poke-helm-send-ask (wrap poke-send-ask):from-helm
++ poke-helm-verb (wrap poke-verb):from-helm
++ poke-helm-begin (wrap poke-begin):from-helm
++ poke-hood-sync (wrap poke-sync):from-kiln

View File

@ -574,22 +574,18 @@
^+ .
=+ [pyz=zip ful=*(set bone)]
|- ^+ +>
?~ pyz
=+ ded=(~(tap in ful) ~)
|- ^+ +>.^$
?~ ded +>.^$
%= $
ded t.ded
+>.^$
%= ap-kill
ost i.ded
q.q.pry p:(~(got by sup.ged) i.ded)
==
==
?. ?=([%give %diff *] q.i.pyz)
$(pyz t.pyz)
=^ vad +> ap-fill(ost p.i.pyz)
$(pyz t.pyz, ful ?:(vad ful (~(put in ful) p.i.pyz)))
?^ pyz
?. ?=([%give %diff *] q.i.pyz)
$(pyz t.pyz)
=^ vad +> ap-fill(ost p.i.pyz)
$(pyz t.pyz, ful ?:(vad ful (~(put in ful) p.i.pyz)))
=+ ded=(~(tap in ful) ~)
|- ^+ +>.^$
?~ ded +>.^$
=> %*(. $(ded t.ded) ost i.ded)
=+ tib=(~(get by sup.ged) ost)
?~ tib ~&([%ap-abut-bad-bone dap ost] ..ap-kill)
ap-kill(q.q.pry p.u.tib)
::
++ ap-aver :: cove to move
|= cov=cove

View File

@ -609,9 +609,12 @@
=. rez ['"' rez]
=+ viz=(trip p.val)
!.
|-
|- ^- tape
?~ viz rez
(weld (jesc i.viz) $(viz t.viz))
=+ hed=(jesc i.viz)
?: ?=([@ ~] hed) :: common case
[i.hed $(viz t.viz)] :: cons-and-tail
(weld hed $(viz t.viz))
::
%o
:- '{'

6
gen/hood/ask.hoon Normal file
View File

@ -0,0 +1,6 @@
:- %say
|= [^ [mel=cord ~] ~]
=+ adr=(star ;~(less (mask "\"\\()[],:;<>@") prn))
=+ dom=[;~(plug dlab dot (most dot dlab))]:urlp
=+ ~|(bad-email/mel (rash mel ;~((glue pat) adr dom)))
helm-send-ask/mel

View File

@ -54,6 +54,7 @@
++ pear :: poke fruit
$% [%hood-unsync desk ship desk] ::
[%talk-command command:talk] ::
[%ask-mail cord] ::
[%helm-hi cord] ::
== ::
--
@ -88,6 +89,11 @@
%^ emit %poke /helm/hi/(scot %p her)
[[her %hood] %helm-hi ?~(mes '' (crip u.mes))]
::
++ poke-send-ask
|= mel=cord =< abet
%^ emit %poke /helm/ask/(scot %p ~doznec)
[[~doznec %ask] %ask-mail mel]
::
++ poke-hi |=(mes=@t abet:(emit %flog /di %text "< {<src>}: {(trip mes)}"))
++ coup-hi
|= [pax=path cop=(unit tang)] =< abet

17
mar/ask-mail.hoon Normal file
View File

@ -0,0 +1,17 @@
::
:::: /hoon/ask-mail/mar
::
/? 314
|_ txt=cord
::
++ grab :: convert from
|%
++ noun ,@t :: clam from %noun
++ json (cork so:jo need)
--
++ grow
|%
++ psal ;div: {(trip txt)}
++ mime [text//plain (taco txt)]
--
--