urbit/main/app/twit/core.hook
2015-01-22 14:11:20 -08:00

110 lines
2.6 KiB
Plaintext

:: Twitter daemon
::
:::: /hook/core/twit/app
::
:: /- twit-do :: XX wherefore broken
/+ twitter
::
:::: ~fyr
::
|%
++ twit-do
$% [%auth p=keys]
[%post p=@uvI q=cord]
==
::
++ sign ,[%e %thou p=httr]
++ note ,[%e %them ~ u=hiss]
++ gift $% [%nice ~]
[%mean p=ares]
[%rush p=gilt]
==
++ gilt $% [%twit-feed p=(list stat)]
[%time p=time]
==
::
++ stat ,[id=@u who=@ta now=@da txt=@t]
++ move ,[bone (mold note gift)]
--
!:
::::
::
|_ [hide kes=(unit keys) out=(map ,@uvI (each cord ,@da))]
++ auth ~|(%no-auth ~(. twit (need kes) lat `@`eny))
++ poke-twit-do
|= [ost=bone @ act=twit-do]
^+ [*(list move) +>]
?- -.act
%auth
:: ~& twit-auth/p.act
=. kes `p.act
:_(+>.$ [ost %give %nice ~]~)
%post
=. out (~(put by out) p.act %& q.act)
:_ +>.$
:- [ost %give %nice ~]
=+ mez=(stat-upda:auth [%status q.act]~ ~)
[ost %pass /post/(scot %uv p.act) %e %them ~ mez]~
==
::
++ pour
|= [ost=bone pax=path sig=sign]
^+ [*(list move) +>]
?+ p.p.sig ~|([%unknown-code p.p.sig] !!)
200
=+ jon=(need (poja q:(need r.p.sig)))
:: ~& twit-resp/%.(jon ?+(-.jon !! %o stat:twir, %a (ar:jo stat:twir)))
?+ pax ~|([%path-missed pax] !!)
[%post @ ~]
=. out (~(put by out) (slav %uv i.t.pax) %| lat)
:_ +>.$
(weld (spam pax %rush %time lat) (spam pax %mean ~))
[%peer *]
:_ +>.$
%^ spam t.pax %rush
~| [%bad-tweets jon]
[%twit-feed (need %.(jon (ar:jo stat:twir)))]
==
?(400 401 403 404)
=- [[ost %give `gift`-]~ +>.$]
=+ err=%.(q:(need r.p.sig) ;~(biff poja mean:twir))
:^ %mean ~ %bad-http
[leaf/"HTTP Code {<p.p.sig>}" (turn (need err) mean:twip)]
==
::
++ peer
|= [ost=bone @ pax=path]
^+ [*(list move) +>]
:_ +>.$
:- [ost %give %nice ~]
?~ pax !!
?: ?=(%post i.pax)
?> ?=([@ ~] t.pax)
=+ sta=(~(get by out) (slav %uv i.t.pax))
?. ?=([~ %| @] sta)
~
:- [ost %give %rush %time p.u.sta]
[ost %give %mean ~]~ :: subscription ended
=- [ost %pass [%peer pax] %e %them ~ `hiss`-]~
?+ i.pax ~|([%missed-prefix i.pax] !!)
%mine
?^ t.pax !!
(stat-home:auth)
%line
?> ?=([@ ~] t.pax)
=- (stat-user:auth [-]~ ~)
^- sd:twit
~| [%not-user i.t.pax]
%+ rash i.t.pax
;~(pose (stag %user-id dem) (stag %screen-name user:twir))
==
::
++ spam
|= [a=path b=gift] ^- (list move)
%+ murn (~(tap by sup))
|= [ost=bone @ pax=path]
^- (unit move)
?. =(pax a) ~
[~ [ost %give b]]
--