urbit/main/bin/chat.hoon

203 lines
6.2 KiB
Plaintext
Raw Normal View History

2013-10-16 06:24:12 +04:00
!:
2014-05-31 02:41:22 +04:00
:: /=main=/bin/chat/hoon
2013-10-16 06:24:12 +04:00
::
2013-11-26 23:28:15 +04:00
=> %= .
+
=> +
=> ^/===/lib/pony
=+ ^= flag
2014-07-03 02:08:02 +04:00
$? [%haus p=@p]
[%s p=path]
==
2014-05-31 02:41:22 +04:00
=+ flags=*(list flag)
2013-11-26 23:28:15 +04:00
=> |%
2014-07-03 02:08:02 +04:00
++ chat :: user action
$% [%all p=mess] :: say
[%back p=@da] :: backlog
[%how ~] :: help
[%who ~] :: who
== ::
++ mess :: message
$% [%do p=@t] :: act
[%exp p=@t q=tank] :: code
[%say p=@t] :: say
== ::
++ station path ::
++ zing :: client to server
$% [%backlog p=path q=@da] ::
[%hola p=station] ::
[%mess p=station q=mess] ::
== ::
++ zong :: server to client
$% [%mess p=@da q=ship r=mess] ::
== ::
--
=> |%
2013-11-26 23:28:15 +04:00
++ chat
2014-07-03 02:08:02 +04:00
|= now=@da
2013-11-26 23:28:15 +04:00
%+ cook |=(a=^chat a)
;~ pose
(cold [%how ~] wut)
2014-07-03 02:08:02 +04:00
(cold [%who ~] tis)
(stag %back (dat now))
(stag %all mess)
2013-11-26 23:28:15 +04:00
==
::
2014-07-03 02:08:02 +04:00
++ dat
|= now=@da
%+ cook
|= [p=@tas q=@]
?+ p `@da`0
%da `@da`q
%dr `@da`(sub now q)
==
;~(pfix (jest '\\\\ ~') crub:so)
2014-05-31 02:41:22 +04:00
::
2013-11-26 23:28:15 +04:00
++ expn
%- sear
:_ text
|= a=@t
^- (unit ,[p=@t q=tank])
=+ hun=(rush a wide:vast)
2013-12-26 21:12:07 +04:00
?~ hun ~
2013-11-26 23:28:15 +04:00
?~(a ~ [~ a (sell (slap seed u.hun))])
::
++ mess
%+ cook |=(a=^mess a)
;~ pose
(stag %do ;~(pfix pat text))
2014-07-03 02:08:02 +04:00
(stag %exp ;~(pfix hax expn))
(stag %do (full (easy '')))
2014-07-03 02:08:02 +04:00
(stag %say text)
2013-11-26 23:28:15 +04:00
==
2014-07-03 02:08:02 +04:00
::
++ text (boss 256 (star prn))
2013-11-26 23:28:15 +04:00
--
|%
++ rend
2014-07-03 02:08:02 +04:00
|= [from=@p msg=^mess] :: roo=^room
2013-11-26 23:28:15 +04:00
^- tank
2014-07-03 02:08:02 +04:00
?- -.msg
%do =+ mes=?:(=(0 p.msg) "remains quietly present" (trip p.msg))
:- %leaf
"{<from>} {mes}"
%exp :~ %rose
[" " "" ""]
:- %leaf
"{<from>} {(trip p.msg)}"
q.msg
==
%say [%leaf "{<from>}: {(trip p.msg)}"]
2013-11-26 23:28:15 +04:00
==
--
2014-07-03 02:08:02 +04:00
::
2013-11-26 23:28:15 +04:00
==
=> %= .
-
2014-07-03 02:08:02 +04:00
:- :* ami=*(set ship)
bud=(sein `@p`-<) :: chat server
2013-11-26 23:28:15 +04:00
dun=| :: done
2014-07-03 02:08:02 +04:00
giz=*(list gift) :: stuff to send
sta=*station :: station
sub=*(list path) :: subscriptions
2013-11-26 23:28:15 +04:00
==
[who=`@p`-< how=`path`->]
==
2013-10-16 06:24:12 +04:00
|= [est=time *]
2014-05-31 02:41:22 +04:00
|= args=(list flag)
2014-07-03 02:08:02 +04:00
=. flags args
=. bud
2014-07-03 02:08:02 +04:00
?: (lien args |=(a=flag ?=(%haus -.a)))
(roll args |=([p=flag q=@p] ?:(?=(%haus -.p) p.p q)))
2014-05-31 02:41:22 +04:00
bud
2014-07-03 02:08:02 +04:00
=. sta
?: (lien args |=(a=flag ?=(%s -.a)))
(roll args |=([p=flag q=station] ?:(?=(%s -.p) p.p q)))
sta
2013-11-26 23:28:15 +04:00
|- ^- bowl
=< abet:init
|%
++ abet `bowl`[(flop giz) ?:(dun ~ [~ hope vent(giz ~)])]
2014-07-03 02:08:02 +04:00
++ hope
:_ (turn sub |=(pax=path [[%gr pax] [%gr ~]]))
[/up [%up %text ["& " ""]]]
2013-11-26 23:28:15 +04:00
::
++ init (subs:(subs:(joke %hola sta) (welp sta /mensajes)) (welp sta /amigos))
2013-11-26 23:28:15 +04:00
++ joke :: send message
2014-07-03 02:08:02 +04:00
|= msg=zing
2013-11-26 23:28:15 +04:00
^+ +>
2014-07-03 02:08:02 +04:00
+>(giz :_(giz [%xz [bud %radio] who %zing msg]))
2013-11-26 23:28:15 +04:00
::
2014-07-03 02:08:02 +04:00
++ join
|= you=ship
2013-11-26 23:28:15 +04:00
^+ +>
2014-07-03 02:08:02 +04:00
%+ show(ami (~(put in ami) you))
%leaf
"{(scow %p you)} comes on the air"
++ joyn
|= yall=(list ship)
2013-11-26 23:28:15 +04:00
^+ +>
2014-07-03 02:08:02 +04:00
%- shew(ami (~(gas in ami) yall))
(turn yall |=(you=ship [%leaf "{(scow %p you)} comes on the air"]))
2013-11-26 23:28:15 +04:00
::
++ said :: server message
2014-07-03 02:08:02 +04:00
|= duz=(list zong)
2013-11-26 23:28:15 +04:00
^+ +>
?~ duz +>
%= $
duz t.duz
+>
=. giz
2014-07-03 02:08:02 +04:00
?. ?& :: ?=(%mess -.i.duz)
=+ ^= r
%+ rexp (scow %p who)
2014-07-03 02:08:02 +04:00
(trip =>(r.i.duz ?@(+ p p)))
&(!=(~ r) !=([~ ~] r) !=([~ ~ ~] r))
==
2014-07-03 02:08:02 +04:00
giz
[[%xy /d [%blit [%bel ~]~]] giz]
2014-07-03 02:08:02 +04:00
%- show
^- tank
?- -.i.duz
2014-07-03 02:08:02 +04:00
%mess (rend q.i.duz r.i.duz)
== ==
2013-11-26 23:28:15 +04:00
::
++ shew |=(tax=(list tank) +>(giz [[%lo tax] giz])) :: print to screen
++ show |=(tan=tank +>(giz [[%la tan] giz])) :: print to screen
2014-07-03 02:08:02 +04:00
::
++ subs
|= pax=path
^+ +>
+>(sub [pax sub], giz :_(giz [%zz /g [%gr pax] %show [bud %radio] who pax]))
2013-11-26 23:28:15 +04:00
::
++ toke :: user action
2014-07-03 02:08:02 +04:00
|= [now=@da txt=@t]
2013-11-26 23:28:15 +04:00
^+ +>
2014-05-31 02:41:22 +04:00
?: =(0 txt) +>
2014-07-03 02:08:02 +04:00
=+ rey=(rush txt (chat now))
?~ rey
2013-11-26 23:28:15 +04:00
(show %leaf "invalid input")
?- -.u.rey
2014-07-03 02:08:02 +04:00
%all (joke %mess sta p.u.rey)
%back (joke %backlog sta p.u.rey)
%how (shew (turn (lore ^:@/===doc%/help/txt) |=(a=@t [%leaf (trip a)])))
%who (show %rose [", " "" ""] (turn (~(tap in ami)) |=(p=ship >p<)))
2013-11-26 23:28:15 +04:00
==
::
++ vent :: handle event
|= [now=@da pax=path nut=note]
^- bowl
=. est now
=< abet
2014-07-03 02:08:02 +04:00
?+ -.pax ~& [%chat-vent-unknown -.nut] +>.$
%gr ?> ?=(%gr -.nut)
?+ p.nut ~& %vent-rush-logo-fail +>.$
%user (join ((hard ship) q.nut))
%users (joyn ((hard (list ship)) q.nut))
%zong (said [((hard zong) q.nut) ~])
%zongs (said ((hard (list zong)) q.nut))
2014-07-03 02:08:02 +04:00
==
%up ?>(?=(%up -.nut) (toke now p.nut))
2013-11-26 23:28:15 +04:00
==
--