Twitter daemon v1: auth, tweeting

This commit is contained in:
Anton Dyudin 2015-01-21 19:31:17 -08:00
parent a418210aca
commit f474850521
9 changed files with 134 additions and 2 deletions

View File

@ -871,7 +871,7 @@
(fine cof `cage`[p.kas vax])
::
%call
%+ cool |.(leaf/"ford: call {<`@p`(mug kas)>}")
:: %+ cool |.(leaf/"ford: call {<`@p`(mug kas)>}")
%. [cof p.kas q.kas]
;~ cope
;~ coax

View File

@ -955,6 +955,10 @@
|= vax=vase
^+ +>
=+ new=?~(huv.sat & !=(+<+.q.vax +<+.q.u.huv.sat))
:: ?. ?=(%core -.p.vax)
:: ~| [%morn-not-core -.p.vax app.sat imp]
:: ~> %mean.|.((skol p.vax))
:: !!
=. huv.sat `vax
?. new +>.$
=: act.sat +(act.sat)

View File

@ -13,6 +13,18 @@
::
++ pour
|= [ost=bone * sih=*]
~& poke-resp/;;([term term] [&1 &2]:sih)
~& =+ cod=(,[term term] [&1 &2]:sih)
?+ +.cod poke-resp/cod
%nice %poke-nice
%mean
=+ are=((soft ares) |2.sih)
?~ are %poke-mean
?~ u.are %poke-nil-mean
~& > p.u.u.are
|-
?~ q.u.u.are %poke-mean
~> %slog.`rose/[~ "! " ~]^[i.q.u.u.are]~
$(q.u.u.are t.q.u.u.are)
==
:_(+> [ost %pass / %g %cide %$]~)
--

8
main/app/tweet/core.hook Normal file
View File

@ -0,0 +1,8 @@
/+ sh-utils
!:
|_ [hide ~]
++ poke--args
%- gate-bang :_ ,_`.
|=([a=cord ~] [%g %mess [our /twit] our %twit-do !>([%post a])])
++ pour |*([ost=@ * sih=[@ ^]] :_(+>.$ [ost %give +.sih]~))
--

58
main/app/twit/core.hook Normal file
View File

@ -0,0 +1,58 @@
:: Twitter daemon
::
:::: /hook/core/twit/app
::
:: /- twit-do :: XX wherefore broken
/+ twitter
::
:::: ~fyr
::
|%
++ twit-do
$% [%auth p=keys]
[%post p=cord]
==
::
++ sign ,[%e %thou p=httr]
++ note ,[%e %them ~ u=hiss]
++ gift $% [%nice ~]
[%mean p=ares]
==
::
++ move ,[bone (mold note gift)]
--
!:
::::
::
|_ [hide vat=(unit keys)]
++ auth ~|(%no-auth ~(. twit (need vat) lat `@`eny))
++ poke-twit-do
|= [ost=bone @ a=twit-do]
^+ [*(list move) +>]
?- -.a
%auth
:: ~& twit-auth/p.a
=. vat `p.a
`+>.$
%post
=+ mez=(stat-upda:auth [%status p.a]~ ~)
:_ +>.$
[ost %pass /post %e %them ~ mez]~
==
::
++ pour
|= [ost=bone * sig=sign]
^+ [*(list move) +>]
?+ p.p.sig ~|([%unknown-code p.p.sig] !!)
200 ~& twit-resp/%.(q:(need r.p.sig) ;~(biff poja stat:twir))
:_ +>.$
[ost %give %nice ~]~
?(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)]
==
::
++ peek ,_psal/;pre:"{(trip (role (turn (wash 0^100 >vat<) crip)))}"
--

View File

@ -0,0 +1,4 @@
:- :- 'AP3G1t8ki6rPzeeAqdWCTw03F'
'VV784LPwZSaAxtF16RWWTnST4F85BHN8VqQKNyv7MprCkA0xZD'
:- '2821727326-RZGXSeTn7hCFQfJqR0ViivM3YYpu2O1M71gelBl'
'jW9VygFPOTsEK0WmrJDHYSoEnofOPdCE1oQRzueemVTl8'

View File

@ -0,0 +1,27 @@
:: Input twitter keys
/+ sh-utils
!:
|_ [hide vat=wain]
++ prompts
`(list cord)`~['App token: ' 'App secret: ' 'User token: ' 'User secret: ' '']
++ peek ,_prompt/[(snag (lent vat) prompts) %text '']
++ posh
|= [@ * %txt p=cord]
=. vat [p vat]
?. =(4 (lent vat)) `+>.$
%.(+< (add-exit ,_`+>.$))
::
++ part
=. vat (flop vat) :: put into order of entry
?. ?=([@ @ @ @ ~] vat)
~|([%keys-missing vat] !!)
=+ =< aut=[[utok usec] atok asec]
`[atok=cord asec=cord utok=cord usec=cord ~]`vat
|= ost=bone
:_ ~
:^ ost %pass /out
[%g %mess serv our %twit-do !>([%auth aut])]
::
++ poke--args (listen-in . (add-nice ,_`.))
++ serv [our /twit]
--

View File

@ -7,6 +7,8 @@
|* a=*
|* b=*
[b a]
::
++ hapt (pair ship path)
--
::
::::
@ -24,6 +26,12 @@
%+ add-resp [%give %nice ~]
ref
::
++ add-subs :: add gall subscription
|* [hat=[hapt ship path] ref=_,[(list) ^]]
=+ `[hapt ship path]`hat :: typecheck
%+ add-resp [%pass /show %g %show hat]
ref
::
++ args-into-gate :: poke--args from gate: output and exit
|* [con=[* [hide *] *] gat=_,[@ *]]
%- args-done
@ -74,6 +82,10 @@
|* [ost=bone * arg=_+<.gat]
((add-output con (gat arg) ref) +<)
::
++ listen-in :: recieve standard input
|* [con=[* [hide *] *] ref=_,[(list) ^]]
(add-subs [[our +.imp] our /in/[-.imp]]:con ref)
::
++ print
|* [con=[* [hide *] *] tap=tape]
(add-output con [%rush %tang [%leaf tap] ~] ,_[~ con])

View File

@ -113,9 +113,16 @@
:::: library
::
|%
++ twip :: response printers
|%
++ mean
|= [msg=@t num=@ud] ^- tank
rose/[": " `~]^~[leaf/"Error {<num>}" leaf/(trip msg)]
--
++ twir :: response parsers
|%
++ fasp |*([a=@tas b=*] [(gsub '-' '_' a) b])
++ mean (ot errors/(ar (ot message/so code/ni ~)) ~):jo
++ stat
=+ jo
^- $+(json (unit ,[id=@u who=@ta now=@da txt=@t]))