shrub/app/ask.hoon

155 lines
4.3 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
2018-10-15 09:03:54 +03:00
/+ sole, prey
=, sole
|%
++ card
$% {$diff $sole-effect sole-effect}
==
2016-08-19 04:10:55 +03:00
++ invited ?($new $sent $ignored)
++ email @t
--
2016-11-17 04:42:58 +03:00
::
=, gall
2016-08-20 03:00:24 +03:00
|_ $: bow/bowl
adr/(map email {time invited})
sos/(map bone sole-share)
wom/(unit ship)
admins/(set ship)
==
2016-08-20 01:26:31 +03:00
++ prompt
^- sole-prompt
2016-08-20 01:26:31 +03:00
?~ wom [& %ask-ship ":womb-ship? ~"]
=/ new new-adrs
?~ new [& %$ "<listening> (0) [l,a,i,w,?]"]
[& %$ ": approve {<ask.i.new>}? ({<(lent new)>}) [y,n,l,a,i,w,?]"]
2016-08-20 01:26:31 +03:00
::
++ peer-sole
|= path
^- (quip {bone card} _+>)
~| [%not-in-whitelist src.bow]
2016-08-20 03:00:24 +03:00
?> |((~(has in admins) src.bow) =(our.bow src.bow))
:_ +>.$(sos (~(put by sos) ost.bow *sole-share))
2016-08-20 01:26:31 +03:00
=- [(effect %mor pro+prompt -)]~
=+ all=adrs
[(render all) (turn all put-mail)]
::
++ render :: show list of invites
|= a/(list {time email invited}) ^- sole-effect
?: =(~ a) txt+"~"
tan+(flop (turn a message))
::
++ 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)))
++ ignored-adrs (skim adrs |=({@ @ inv/invited} =(%ignored 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 ~))
==
::
2016-08-20 03:00:24 +03:00
++ poke-ask-admins
|= a/(set ship)
?> =(our.bow src.bow)
`+>.$(admins a)
::
++ 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
2017-10-19 22:24:42 +03:00
^- (quip {bone card} _+>)
2016-08-20 01:26:31 +03:00
=/ 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)
2018-03-19 06:54:47 +03:00
?. ?=({%& ^} try)
2016-08-20 01:26:31 +03:00
[[(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
2018-12-12 00:59:49 +03:00
=^ 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 (render adrs) ~)
?: =(`*`"l" buf.som) (transmit inv (render new-adrs) ~)
?: =(`*`"i" buf.som) (transmit inv (render ignored-adrs) ~)
?: =(`*`"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)
2018-12-12 00:59:49 +03:00
=^ det som (~(transmit sole som) inv)
2016-08-20 01:41:48 +03:00
=. 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
i - list ignored 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
2018-10-15 09:03:54 +03:00
~| %ask-stub-invite
!!
--