shrub/app/ask.hoon

142 lines
4.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-20 02:41:32 +03:00
{$poke wire {ship $hood} $womb-invite {cord reference invite}:womb}
==
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
^- sole-prompt
2016-08-20 01:26:31 +03:00
?~ wom [& %ask-ship ":womb-ship? ~"]
=/ new new-adrs
?~ new [& %$ "<listening> (0) [l,a,w,?]"]
[& %$ ": approve {<ask.i.new>}? ({<(lent new)>}) [y,n,l,a,w,?]"]
2016-08-20 01:26:31 +03:00
::
++ 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 (flop all) message) (turn all put-mail)]
::
++ adrs
=- (sort - lor)
%+ turn (~(tap by adr))
|=({a/email b/time c/invited} [tym=b ask=a inv=c])
::
++ new-adrs (skim adrs |=({@ @ inv/invited} =(%new inv)))
++ 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
:_ +>.$
2016-08-19 04:10:55 +03:00
=/ new [now.bow ask %new]
=+ [mez=[(message new)]~ pro=prompt sav=(put-mail new)]
%+ turn (prey /sole bow)
|=({ost/bone ^} (effect(ost.bow ost) %mor tan+mez pro+prompt 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
2016-08-20 01:41:48 +03:00
?: =(~ buf.som) [[(effect txt+"Please enter womb ship")]~ +>.$]
2016-08-20 01:26:31 +03:00
=/ try (rose (tufa buf.som) fed:ag)
?. ?=({$& ^} try)
[[(effect bel+~)]~ +>.$]
=> .(wom p.try) :: XX TMI
2016-08-20 01:41:48 +03:00
(transmit set+~ pro+prompt ~) :: XX handle multiple links?
2016-08-20 01:26:31 +03:00
::
$det :: reject all input
=^ inv som (~(transceive sole som) +.act)
2016-08-20 01:41:48 +03:00
=. sos (~(put by sos) ost.bow som)
2016-08-20 01:26:31 +03:00
?~ wom
=/ try (rose (tufa buf.som) fed:ag)
2016-08-20 01:41:48 +03:00
?: -.try `+>.$
(transmit inv bel+~ ~)
?: =(`*`"?" buf.som) (transmit inv help)
?: =(`*`"a" buf.som) (transmit inv tan+(turn (flop adrs) message) ~)
?: =(`*`"l" buf.som) (transmit inv tan+(turn (flop new-adrs) message) ~)
?: =(`*`"n" buf.som)
=/ new new-adrs
?~ new (transmit inv bel+~ ~)
=. inv.i.new %ignored
=. adr (~(put by adr) ask.i.new [tym inv]:i.new)
(transmit inv tan+[(message i.new)]~ pro+prompt ~)
2016-08-20 02:41:32 +03:00
?: =(`*`"y" buf.som)
=/ new new-adrs
?~ new (transmit inv bel+~ ~)
=. inv.i.new %sent :: XX pending
=- [[(invite ask.i.new) -<] ->]
=. adr (~(put by adr) ask.i.new [tym inv]:i.new)
(transmit inv tan+[(message i.new)]~ pro+prompt ~)
2016-08-20 01:42:04 +03:00
?: =(`*`"w" buf.som)
=> .(wom ~) :: XX TMI
(transmit inv pro+prompt ~)
(transmit inv bel+~ ~)
==
2016-08-20 01:41:48 +03:00
++ transmit
|= {inv/sole-edit mor/(list sole-effect)}
=/ som (~(got by sos) ost.bow)
=^ 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))))
%+ welp
?~ [new-adrs] ""
"""
y - invite current ask
n - ignore current ask
"""
2016-08-19 04:10:55 +03:00
"""
2016-08-20 00:36:09 +03:00
l - list new asks
2016-08-19 22:37:09 +03:00
a - list all asks
2016-08-20 01:42:04 +03:00
w - reset womb ship
2016-08-19 22:37:09 +03:00
? - print help
2016-08-19 04:10:55 +03:00
"""
2016-08-20 01:26:31 +03:00
::
++ invite
|= ask/email
2016-08-20 02:41:32 +03:00
:- ost.bow
^- card
:^ %poke /invite/(scot %t ask) [(need wom) %hood]
2016-08-20 01:26:31 +03:00
:- %womb-invite
^- {cord reference invite}:womb
=+ inv=(scot %uv (end 7 1 eny.bow))
[inv `&+our.bow [ask 1 0 "You have been invited to Urbit: {(trip inv)}" ""]]
--