urbit/ape/ask.hoon

58 lines
1.6 KiB
Plaintext
Raw Normal View History

::
2015-12-20 14:48:17 +03:00
:::: /hoon#ask#ape
::
/? 314
/+ sole
[. sole]
|%
++ card
2015-12-15 03:45:52 +03:00
$% {$diff $sole-effect sole-effect}
==
--
!:
2015-12-20 23:50:45 +03:00
|_ {bow/bowl adr/(set cord) sos/(map bone sole-share)}
++ peer-sole
|= path
2015-12-15 03:45:52 +03:00
^- (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))
2015-12-20 14:48:17 +03:00
=- [(effect %mor pro#[& %$ "<listening>"] -)]~
=+ all=adrs
2015-12-20 14:48:17 +03:00
[tan#(turn all message) (turn all put-mail)]
::
++ adrs (sort (~(tap by adr)) aor)
2015-12-20 23:50:45 +03:00
++ 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
2015-12-20 23:50:45 +03:00
|= ask/@t
2015-12-15 03:45:52 +03:00
^- (quip {bone card} +>)
2015-12-20 14:48:17 +03:00
~| have-mail#ask
?< (~(has in adr) ask)
:_ +>.$(adr (~(put in adr) ask))
=+ [mez=[(message ask)]~ sav=(put-mail ask)]
%+ turn (prey /sole bow)
2015-12-20 23:50:45 +03:00
|=({ost/bone ^} (effect(ost.bow ost) %mor tan#mez sav ~))
::
++ poke-sole-action
2015-12-20 23:50:45 +03:00
|= act/sole-action
2015-12-15 03:45:52 +03:00
^- (quip {bone card} +>)
?- -.act
2015-12-15 03:45:52 +03:00
$clr `+>.$
2015-12-20 14:48:17 +03:00
$ret [[(effect tan#(turn adrs message))]~ +>.$] :: re-print list
2015-12-15 03:45:52 +03:00
$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)
2015-12-20 14:48:17 +03:00
[[(effect det#det)]~ +>.$]
==
--