shrub/app/ask.hoon

106 lines
3.1 KiB
Plaintext
Raw Normal View History

::
2016-02-05 06:05:37 +03:00
:::: /hoon/ask/app
::
2016-02-18 01:57:46 +03:00
/? 310
2016-08-20 01:26:31 +03:00
/+ sole, womb
[. sole]
|%
++ card
$% {$diff $sole-effect sole-effect}
==
2016-08-19 04:10:55 +03:00
++ invited ?($new $sent $ignored)
++ email @t
--
!:
2016-08-20 01:26:31 +03:00
|_ {bow/bowl adr/(map email {time invited}) sos/(map bone sole-share) wom/(unit ship)}
++ prompt
?~ wom [& %ask-ship ":womb-ship? ~"]
[& %$ "<listening> [l,a,?]"]
::
++ peer-sole
|= path
^- (quip {bone card} +>)
~| [%not-in-whitelist src.bow]
2016-08-20 01:26:31 +03:00
?> (~(has in (sy ~zod our.bow ~wisdyr-holpeg ~)) src.bow)
:_ +>.$(sos (~(put by sos) ost.bow *sole-share))
2016-08-20 01:26:31 +03:00
=- [(effect %mor pro+prompt -)]~
=+ all=adrs
[tan+(turn all message) (turn all put-mail)]
::
2016-08-19 04:10:55 +03:00
++ adrs (sort (turn (~(tap by adr)) |=({a/email b/time c/invited} [b a c])) lor)
++ effect |=(fec/sole-effect [ost.bow %diff %sole-effect fec])
2016-08-19 04:10:55 +03:00
++ message
|= {now/time ask/@t inv/invited} ^- tank
=. now (sub now (mod now ~s1))
leaf+"ask: {<inv>} {<now>} {(trip ask)}"
::
++ put-mail |=({@ ask/@t inv/invited} =+(pax=(rash ask unix-path) [%sav pax `@t`inv]))
++ 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
2016-08-19 04:10:55 +03:00
?< (~(has by adr) ask)
:_ +>.$(adr (~(put by adr) ask now.bow %new)) :: XX electroplating
=/ new [now.bow ask %new]
=+ [mez=[(message new)]~ sav=(put-mail new)]
%+ turn (prey /sole bow)
|=({ost/bone ^} (effect(ost.bow ost) %mor tan+mez sav ~))
::
++ poke-sole-action
|= act/sole-action
2016-08-20 01:26:31 +03:00
^- (quip {bone card} +>)
=/ som (~(got by sos) ost.bow)
?- -.act
$clr `+>.$
$ret
?^ wom [[(effect mor+help)]~ +>.$] :: show help
?~ buf.som [[(effect txt+"Please enter womb ship")]~ +>.$]
=/ try (rose (tufa buf.som) fed:ag)
?. ?=({$& ^} try)
[[(effect bel+~)]~ +>.$]
=> .(wom p.try) :: XX TMI
[[(effect pro+prompt)]~ +>.$] :: XX handle multiple links?
::
$det :: reject all input
=^ inv som (~(transceive sole som) +.act)
?~ wom
=/ try (rose (tufa buf.som) fed:ag)
?: -.try `+>.$(sos (~(put by sos) ost.bow som))
=^ det som (~(transmit sole som) inv)
=. sos (~(put by sos) ost.bow som)
2016-08-20 01:26:31 +03:00
[[(effect mor+~[det+det bel+~])]~ +>.$]
=/ mor/(list sole-effect)
?: =(`*`"?" buf.som) help
?: =(`*`"a" buf.som) [tan+(turn adrs message)]~
?: =(`*`"l" buf.som)
=; new [tan+(turn new message)]~
(skim adrs |=({@ @ inv/invited} =(%new inv)))
~
=^ det som (~(transmit sole som) inv)
=. sos (~(put by sos) ost.bow som)
[[(effect mor+[det+det mor])]~ +>.$]
==
2016-08-20 00:36:09 +03:00
::
2016-08-19 04:10:55 +03:00
++ help
^- (list sole-effect)
=- (scan - (more (just '\0a') (stag %txt (star prn))))
"""
2016-08-20 00:36:09 +03:00
l - list new asks
2016-08-19 22:37:09 +03:00
a - list all asks
? - print help
2016-08-19 04:10:55 +03:00
"""
2016-08-20 01:26:31 +03:00
::
++ invite
|= who/email
:- %womb-invite
^- {cord reference invite}:womb
=+ inv=(scot %uv (end 7 1 eny.bow))
[inv `&+our.bow [who 1 0 "You have been invited to Urbit: {(trip inv)}" ""]]
--