chat is this real??

This commit is contained in:
hanfel-dovned 2024-05-29 14:37:33 -07:00 committed by bonbud-macryg
parent 70f2f329a1
commit 64efbc4f43
12 changed files with 336 additions and 56 deletions

View File

@ -1,67 +1,74 @@
/@ dm-diff
/@ message
=>
|%
++ card card:neo
--
^- kook:neo
|%
++ state pro/%sig
++ poke (sy %dm-diff %rely ~)
++ state pro/%ship :: who I'm chatting with
++ poke (sy %dm-diff ~)
++ kids
:+ ~ %y
%- ~(gas by *lads:neo)
:~ :- [|/%da |]
[pro/%message ~]
==
++ deps
%- ~(gas by *deps:neo)
:~
::
:- %link
::
:+ req=| [pro/%sig (sy %dm-diff ~)]
:+ ~ %y
%- ~(gas by *lads:neo)
:~ :- [|/%da |]
[pro/%message ~]
==
:~ :- [|/%theirs |]
[pro/%message-pub (sy %sig ~)]
:- [|/%mine |]
[pro/%message-sub (sy %sig ~)]
==
++ deps *deps:neo
++ form
^- form:neo
|_ [=bowl:neo =aeon:neo sta=pail:neo]
++ poke
|= [=stud:neo vax=vase]
^- (quip card:neo pail:neo)
?: =(%rely stud)
=+ !<([=term =stem:neo] vax)
?> ?=(%y -.q.stem)
=/ =pail:neo pail:(snag 0 ~(val by kids.q.stem))
=+ !<(=message q.pail)
:: TODO handle
?< =(our.bowl from.message)
:_ sta
:_ ~
:*
(welp here.bowl ~[da/now.bowl])
%make
[%message `pail ~]
==
?> =(%dm-diff stud)
=/ poke !<(dm-diff vax)
?> =(our ship.src):bowl
?> =(%msg -.poke)
:_ sta
:~
:*
(welp were.bowl ~[da/now.bowl])
%make
[%message `message/!>(message.poke) ~]
==
==
|_ [=bowl:neo =aeon:neo state=pail:neo]
++ init
|= old=(unit pail:neo)
^- (quip card:neo pail:neo)
`sig/!>(~)
?~ old !!
?> =(%dm-diff p.u.old)
=/ poke !<(dm-diff q.u.old)
?+ -.poke !!
:: create me with a pith to a service provider
:: to start a new DM with them
%initiate
:_ ship/!>(partner.poke)
:~ :- (snoc here.bowl %pub)
[%make %message-pub ~ ~]
::
:- provider.poke
[%poke dm-diff/!>([%invited here.bowl])]
==
::
:: create me with a pith to an inviter's dm
:: to accept their DM request
%invited
:_ ship/!>(partner.poke)
:~ :- (snoc here.bowl %pub)
[%make %message-pub ~ ~]
::
:- (snoc here.bowl %sub)
[%make %message-sub ~ (malt ~[[%pub dm.poke]])]
::
:- dm.poke
[%poke dm-diff/!>([%acked here.bowl])]
==
==
++ poke
|= [=stud:neo vax=vase]
^- (quip card:neo pail:neo)
?> =(%dm-diff stud)
=/ poke !<(dm-diff vax)
?+ -.poke !!
:: invitee pokes me with a pith to their DM
:: to finalize the negotiation
%acked
=/ partner !<(ship q.state)
?> =(partner ship.src.bowl)
:_ state
:~ :- (snoc here.bowl %sub)
[%make %message-sub ~ (malt ~[[%pub dm.poke]])]
==
::
%post
?> =(our ship.src):bowl
:_ state
:~ :- (snoc here.bowl %pub)
[%poke txt/!>(text.poke)]
==
==
--
--
--

View File

@ -0,0 +1,81 @@
/@ groupchat
/@ groupchat-diff
^- kook:neo
|%
++ state pro/%groupchat
++ poke (sy %groupchat-diff ~)
++ kids
:+ ~ %y
%- ~(gas by *lads:neo)
:~ :- [|/%pub |]
[pro/%message-pub (sy %sig ~)]
:- [|/%sub |]
[pro/%message-sub (sy %sig ~)]
==
++ deps *deps:neo
++ form
^- form:neo
|_ [=bowl:neo =aeon:neo state=pail:neo]
++ init
|= old=(unit pail:neo)
^- (quip card:neo pail:neo)
:: default case: make new groupchat with self as only member,
:: and subscribe to that publisher
:: XX - maybe move ordering is unpredictable here
?~ old
:_ groupchat/!>([~ (snoc here.bowl %pub)])
:~ :- (snoc here.bowl %pub)
[%make %message-pub ~ ~]
::
:- (snoc here.bowl %sub)
[%make %message-sub ~ (malt ~[[%pub (snoc here.bowl %pub)]])]
==
:: otherwise, I've been created as an invitee to
:: someone else's groupchat
?> =(%groupchat-diff p.u.old)
=/ poke !<(groupchat-diff q.u.old)
?+ -.poke !!
%invited
:_ groupchat/!>([~ (snoc chat.poke %pub)])
:~ :- (snoc here.bowl %sub)
[%make %message-sub ~ (malt ~[[%pub (snoc chat.poke %pub)]])]
::
:- chat.poke
[%poke groupchat-diff/!>([%acked ~])]
==
==
++ poke
|= [=stud:neo vax=vase]
^- (quip card:neo pail:neo)
?> =(%groupchat-diff stud)
=/ sta !<(groupchat q.state)
=/ poke !<(groupchat-diff vax)
?+ -.poke !!
:: if I'm the host, poke someone's provider to invite them to chat
%invite
?> =(our ship.src):bowl
:: ?> =(our.bowl ->.publisher.sta) :: XX need @p, have @t ?
:_ :- %groupchat
!>(sta(pending (~(put in pending.sta) ship.poke)))
:~ :- provider.poke
[%poke groupchat-diff/!>([%invited here.bowl])]
==
::
:: when invitee acks, remove them from pending
:: and add them to pub's permissions
%acked
?> (~(has in pending.sta) ship.src.bowl)
:_ :- %groupchat
!>(sta(pending (~(del in pending.sta) ship.src.bowl)))
:~ :- publisher.sta
[%poke ships-diff/!>([%put ship.src.bowl])]
==
::
%post
:_ state
:~ :- publisher.sta
[%poke txt/!>(text.poke)]
==
==
--
--

View File

@ -0,0 +1,48 @@
/@ ships
/@ ships-diff
/@ txt
::
^- kook:neo
|%
++ state pro/%ships :: ships that are allowed to post
++ poke (sy %txt %ships-diff ~)
++ kids
:+ ~ %y
%- ~(gas by *lads:neo)
:~ :- [|/%da |]
[pro/%message (sy %sig ~)]
==
++ deps *deps:neo
++ form
^- form:neo
|_ [=bowl:neo =aeon:neo state=pail:neo]
++ init
|= old=(unit pail:neo)
^- (quip card:neo pail:neo)
[~ ships/!>((sy our.bowl ~))]
::
++ poke
|= [=stud:neo vax=vase]
^- (quip card:neo pail:neo)
=/ members !<(ships q.state)
?+ stud !!
%txt
?> (~(has in members) ship.src.bowl)
=/ contents=@t !<(txt vax)
:_ state
:~ :- (welp here.bowl ~[da/now.bowl])
[%make %message `message/!>([ship.src.bowl now.bowl contents]) ~]
==
::
%ships-diff
?> =(our ship.src):bowl
=/ poke !<(ships-diff vax)
?- -.poke
%put
[~ ships/!>((~(put in members) ship.poke))]
%del
[~ ships/!>((~(del in members) ship.poke))]
==
==
--
--

View File

@ -0,0 +1,51 @@
/@ message
^- kook:neo
|%
++ state pro/%sig
++ poke ~
++ kids
:+ ~ %y
%- ~(gas by *lads:neo)
:~ :- [|/%da |]
[pro/%message ~]
==
++ deps
%- ~(gas by *deps:neo)
:~ :- %pub
:+ req=& [pro/%sig (sy %sig ~)]
:+ ~ %y
%- ~(gas by *lads:neo)
:~ :- [|/%da |]
[pro/%message ~]
==
==
++ form
^- form:neo
|_ [=bowl:neo =aeon:neo state=pail:neo]
++ init
|= old=(unit pail:neo)
^- (quip card:neo pail:neo)
[~ sig/!>(~)]
::
++ poke
|= [=stud:neo vax=vase]
^- (quip card:neo pail:neo)
?> =(%rely stud)
:_ state
=+ !<([=term =stem:neo] vax)
?> ?=(%y -.q.stem)
:: only get new kids
=/ kids
%+ skim
~(val by kids.q.stem)
|= [=ever:neo =mode:neo =pail:neo]
=(%add mode)
?: =(~ kids)
~
=/ pai=pail:neo pail:(snag 0 kids)
=/ mes !<(message q.pai)
:~ :- (welp here.bowl ~[da/now.mes])
[%make [%message `pai ~]]
==
--
--

View File

@ -0,0 +1,71 @@
/@ dm-diff
/@ groupchat-diff
/@ messenger-diff
^- kook:neo
|%
++ state pro/%sig
++ poke (sy %dm-diff %groupchat-diff ~)
++ kids
:+ ~ %y
%- ~(gas by *lads:neo)
:~ :- [|/%t |]
[pro/%dm (sy %dm-diff ~)]
:- [|/%t |]
[pro/%groupchat (sy %groupchat-diff ~)]
==
++ deps *deps:neo
++ form
^- form:neo
|_ [=bowl:neo =aeon:neo state=pail:neo]
++ init
|= old=(unit pail:neo)
^- (quip card:neo pail:neo)
[~ sig/!>(~)]
::
++ poke
|= [=stud:neo vax=vase]
^- (quip card:neo pail:neo)
?+ stud !!
%dm-diff
=/ poke !<(dm-diff vax)
?> =(%invited -.poke)
:_ state
:~ :- (snoc here.bowl p/ship.src.bowl)
[%make %dm `dm-diff/vax ~]
==
::
%groupchat-diff
=/ poke !<(groupchat-diff vax)
?> =(%invited -.poke)
:_ state
:~ :- (snoc here.bowl (rear pith.src.bowl))
[%make %groupchat `groupchat-diff/vax ~]
==
::
%messenger-diff
?> =(our ship.src):bowl
=/ poke !<(messenger-diff vax)
?- -.poke
%new-dm
=/ provider ~[p/partner.poke %home %messenger]
:_ state
:~ :- (snoc here.bowl p/partner.poke)
[%make %dm `dm-diff/!>([%initiate partner.poke provider]) ~]
==
::
%new-groupchat
:_ state
:~ :- (snoc here.bowl t/name.poke)
[%make %groupchat ~ ~]
==
::
%invite-to-groupchat
=/ provider ~[p/ship.poke %home %messenger]
:_ state
:~ :- (snoc here.bowl t/name.poke)
[%poke groupchat-diff/!>([%invite ship.poke provider])]
==
==
==
--
--

View File

@ -1,2 +1,7 @@
/@ message
,[%msg =message]
$% [%initiate partner=ship provider=pith]
[%invited partner=ship dm=pith]
::
[%acked dm=pith]
::
[%post text=@t]
==

View File

@ -0,0 +1,5 @@
$% [%invite =ship provider=pith]
[%invited chat=pith]
[%acked ~]
[%post text=@t]
==

View File

@ -0,0 +1,3 @@
$: pending=(set ship)
publisher=pith
==

View File

@ -0,0 +1,4 @@
$% [%new-dm partner=ship]
[%new-groupchat name=@t]
[%invite-to-groupchat name=@t =ship]
==

View File

@ -0,0 +1 @@
ship

View File

@ -0,0 +1,3 @@
$% [%put =ship]
[%del =ship]
==

View File

@ -0,0 +1 @@
(set ship)