Twitter sync

This commit is contained in:
Anton Dyudin 2014-12-15 16:07:16 -08:00
parent c31b87a755
commit edc4399024
2 changed files with 103 additions and 36 deletions

View File

@ -59,6 +59,8 @@
[%nuke p=hapt q=ship] :: cancel
[%show p=hapt q=ship r=path] :: subscribe
== == == ::
++ twim :: twitter endpoints
?(%line %mine %frie %stat)
--
|_ [hid=hide house]
++ ti
@ -68,10 +70,27 @@
:- '2821727326-RZGXSeTn7hCFQfJqR0ViivM3YYpu2O1M71gelBl'
'jW9VygFPOTsEK0WmrJDHYSoEnofOPdCE1oQRzueemVTl8'
==
=- |%
++ sta |=(who=span `station`[%| %twitter who])
++ graze
^- $+(cord (unit (list telegram)))
=- ;~(biff poja (cu:jo - line))
|* a=(list) %+ turn a
|= [id=@u who=@ta now=@da txt=@t]
^- telegram
:* our.hid :: XX correct?
(shaf %twit id)
[[(sta who) %received] `~]
now
[%say txt]
==
--
=> ~(. twit key lat.hid `@`eny.hid)
|%
++ post |=(a=cord `hiss`(stat-upda [%status a]~ ~))
++ stalk |=(a=span `hiss`(stat-user [%screen-name a]~ ~))
++ mine `hiss`(stat-home)
++ frie `hiss`(frie-list)
::
++ line (ar:jo stat:twir) :: parse timeline
--
@ -98,6 +117,10 @@
~& [%ra-evil msg]
(ra-emit ost %give %mean ~ msg ~)
::
++ ra-hiss :: emit http request
|= [pax=path hiz=hiss]
(ra-emit ost %pass pax %e %them ~ hiz)
::
++ ra-house :: emit stations
|= ost=bone
%+ ra-emit ost
@ -123,16 +146,23 @@
%design
?. =(her our.hid)
(ra-evil %radio-no-owner)
=+ pur=(~(get by parties) p.cod)
?~ q.cod
?~ pur
(ra-evil %radio-no-party)
=. +>.$ pa-abet:(~(pa-reform pa p.cod u.pur) *config)
=. +>.$ ra-homes
ra-ever(parties (~(del by parties) p.cod))
=+ poy=`(pair ,? party)`?~(pur [| *party] [& u.pur])
=. +>.$ pa-abet:(~(pa-reform pa p.cod q.poy) u.q.cod)
=. +>.$ ?:(p.poy +>.$ ra-homes)
?. =('.' (end 3 1 p.cod))
?. (~(has by parties) p.cod)
(ra-evil %radio-no-party)
=. +>.$ (ra-config p.cod *config)
ra-ever(parties (~(del by parties) p.cod))
=+ pan=(rsh 3 1 p.cod)
?. ?=(_-:*partner pan)
(ra-evil %radio-party-reserved)
?- pan
%twitter
=> (ra-hiss /twitter/mine mine:ti)
(ra-hiss /twitter/frie frie:ti)
==
?: =('.' (end 3 1 p.cod))
(ra-evil %radio-reserved-design)
=. +>.$ (ra-config p.cod u.q.cod)
ra-ever
::
%review ra-ever:(ra-think | her +.cod)
@ -145,6 +175,14 @@
(~(pa-notify pa p.cod u.pur) her q.cod)
==
::
++ ra-config :: configure party
|= [man=span con=config]
^+ +>
=+ :- neu=(~(has by parties) man)
pur=(fall (~(get by parties) man) *party)
=. +>.$ pa-abet:(~(pa-reform pa man pur) con)
?:(neu +>.$ ra-homes)
::
++ ra-friend :: %friend response
|= [man=span sih=sign]
^+ +>
@ -153,22 +191,35 @@
pa-abet:(~(pa-friend pa man u.pur) sih)
::
++ ra-twitter :: %twitter response
|= [man=span sih=sign]
|= [met=twim sih=sign]
^+ +>
?> ?=(%thou +<.sih)
?. &(=(2 (div p.p.sih 100)) ?=(^ r.p.sih))
~& timeline-lost/[p `(unit ,[@ @t])`r]:[p.sih .]
~& [%twit-lost met [p `(unit ,[@ @t])`r]:[p.sih .]]
+>
~& :- %timeline-found
^- (list thought)
%+ turn (need %.(q.u.r.p.sih ;~(biff poja line:ti)))
|= [id=@u who=@ta now=@da txt=@t] ^- thought
:* (shaf %twit id)
[[[%| twitter/who] %received] `~]
now
[%say txt]
==
+>
?- met
%stat
~& [%tweet-ack p.p.sih]
+>.$
%frie
=+ ^- who=(list ,@ta)
(need %.(q.u.r.p.sih ;~(biff poja usel:twir)))
~& friends-found/who
=+ =< hacks=parties :: XX stateless
(ra-config '.twitter' (sa (turn who sta:ti)) %& ~)
+>.$(parties (~(put by parties) '.twitter' (~(got by hacks) '.twitter')))
%line
=+ gaz=(need (graze:ti q.u.r.p.sih))
~& timeline-found/gaz
+>.$
%mine
=+ pur=(~(get by parties) '.twitter')
?~ pur
$(+> (ra-config '.twitter' *config))
=+ gaz=(need (graze:ti q.u.r.p.sih))
~& timemine-found/gaz
pa-abet:(~(pa-lesson pa '.twitter' u.pur) gaz)
==
::
++ ra-repeat :: %repeat response
|= [num=@ud her=ship man=span sih=sign]
@ -264,9 +315,9 @@
%own "@{(trip p.p.tay)} {<her>} {(trip p.q.r.tip)}"
==
?< (gth (lent msg) 140)
%+ ra-emit ost
:+ %pass /tweet/(scot %ud ost)
[%e %them ~ (post:ti (crip msg))]
%+ ra-hiss
/twitter/stat/(scot %ud ost)
(post:ti (crip msg))
== ==
::
++ ra-record :: add to party
@ -393,7 +444,7 @@
=+ num=(fall (~(get by sequence) tay) 0)
?- -.tay
%| ~& tweet-asked/p.p.tay
:- /twitter/[p.p.tay]
:- /twitter/line/[p.p.tay]
[%e %them ~ (stalk:ti p.p.tay)]
%& ~& [%pa-acquire [our.hid man] [p.p.tay q.p.tay]]
:- /friend/show/[man]
@ -490,6 +541,23 @@
:- p.old
[[p.n.guests %give %rust %radio-report %grams num gam ~] q.old]
=. moves (welp q.moy moves)
=. moves
%- welp :_ moves
~& pa-stat/man
?. =('.' (end 3 1 man))
~
=+ pan=(rsh 3 1 man)
?. ?=(_-:*partner pan)
~&(%radio-party-reserved !!) :: XX ra-evil
~& [%pa-outgoing pan gam]
?- pan
%twitter
:: ?> =(our.hid p.gam)
~& q.r.q.gam
=+ msg=?+(-.q.r.q.gam !! %say (trip p.q.r.q.gam))
?< (gth (lent msg) 140)
[ost %pass /twitter/stat %e %them ~ (post:ti (crip msg))]~
==
|- ^+ +>.^$
?~ p.moy +>.^$
$(p.moy t.p.moy, guests (~(del by guests) i.p.moy))
@ -550,15 +618,8 @@
=+ sih=((hard sign) sih)
?+ pax ~& [%rodeo-strange-path pax] !!
[%twitter *]
?> ?=([@ ~] t.pax)
?> ?=([twim *] t.pax)
ra-abet:(~(ra-twitter ra ost ~) i.t.pax sih)
[%tweet ^]
?> ?=(%thou +<.sih)
~& ?: =(2 (div p.p.sih 100))
[%tweet-ack p.p.sih]
~! sih
[%tweet-lost [p `(unit ,[@ @t])`r]:[p.sih .]]
[~ +>.$]
[%friend *]
?> ?=([@ @ ~] t.pax)
?. =(%show i.t.pax)

View File

@ -115,15 +115,21 @@
|%
++ twir :: response parsers
|%
++ fasp |*([a=@tas b=*] [(gsub '-' '_' a) b])
++ stat
=> jo
=+ jo
^- $+(json (unit ,[id=@u who=@ta now=@da txt=@t]))
%- ot
:~ id/ni
user/(ot ['screen_name' so] ~)
['created_at' da]
user/(ot (fasp screen-name/so) ~)
(fasp created-at/da)
text/so
==
++ usel
=+ jo
^- $+(json (unit (list ,who=@ta)))
=- (ot users/(ar -) ~)
(ot (fasp screen-name/so) ~)
--
++ twit
=> |% :: request structures