From 83007d6c30a549a8e19e8a7cc659d263115e9bdc Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Mon, 26 Jan 2015 19:43:38 -0800 Subject: [PATCH] Added discrimination per commanding twitter user --- main/app/tweet/core.hook | 3 ++- main/app/twit/core.hook | 32 +++++++++++++++----------- main/app/twitter-auth/core.hook | 19 ++++++++++----- main/app/twitter-auth/hoontap-keys.txt | 1 + main/app/twitter-feed/core.hook | 5 +++- main/sur/twitter/core.hook | 3 ++- 6 files changed, 40 insertions(+), 23 deletions(-) diff --git a/main/app/tweet/core.hook b/main/app/tweet/core.hook index 1aed28de6..70ec4de0b 100644 --- a/main/app/tweet/core.hook +++ b/main/app/tweet/core.hook @@ -4,7 +4,8 @@ ++ peer ,_`. ++ poke--args %+ add-subs [[our /twit] our /post/(scot %uv eny)] - %^ gate-mess . |=([a=cord ~] [/twit %twit-do !>([%post eny a])]) + %^ gate-mess . + |=([a=span b=cord ~] [/twit %twit-do !>([a %post eny b])]) ,_`. ++ posh-twit-stat (args-into-gate . |=([@ @ a=@da @] tang/~[leaf/"Tweet recieved {}"])) diff --git a/main/app/twit/core.hook b/main/app/twit/core.hook index e9b9a148b..7242edc6a 100644 --- a/main/app/twit/core.hook +++ b/main/app/twit/core.hook @@ -9,15 +9,15 @@ :: |% ++ twit-path :: valid peer path - $% [%home ~] :: home timeline + $% :: [%home ~] :: home timeline [%user p=@t ~] :: user's tweets [%post p=@ta ~] :: status of status == :: ++ axle :: app state $: %0 - kes=(unit keys) :: auth - out=(map ,@uvI (each cord stat)) :: sent tweets + kes=(map span keys) :: auth + out=(map ,@uvI (each ,[span cord] stat)) :: sent tweets ran=(map path ,[p=@ud q=@da]) :: polls active fed=(jar path stat) :: feed cache == @@ -50,7 +50,12 @@ :::: :: |_ [hide axle] -++ auth ~|(%no-auth ~(. twit (need kes) lat `@`eny)) :: build API door +++ any-auth ?~(kes (auth) (auth p.n.kes)) :: use any keys +++ auth :: build API door + |= a=span + ~| [%no-auth a] + ~(. twit (~(got by kes) a) lat `@`eny) +:: ++ cull :: remove seen tweets |= [pax=path rep=(list stat)] ^+ rep =+ pev=(sa (turn (~(get ja fed) pax) |=(stat id))) @@ -80,19 +85,19 @@ ++ poke-twit-do :: recieve request |= [ost=bone @ act=twit-do] ^+ [*(list move) +>] - ?- -.act + ?- -.q.act %auth :: ~& twit-auth/p.act - =. kes `p.act + =. kes (~(put by kes) p.act p.q.act) :_(+>.$ [ost %give %nice ~]~) :: XX verify key %post - =: out (~(put by out) p.act %& q.act) + =: out (~(put by out) p.q.act %& p.act q.q.act) ran (~(del by ran) /peer/home) == %^ wait ost /peer/home :- [ost %give %nice ~] - =+ mez=(stat-upda:auth [%status q.act]~ ~) - [ost %pass /post/(scot %uv p.act) %e %them ~ mez]~ + =+ mez=(stat-upda:(auth p.act) [%status q.q.act]~ ~) + [ost %pass /post/(scot %uv p.q.act) %e %them ~ mez]~ == :: ++ pour :: recieve response @@ -178,12 +183,11 @@ ?~ ole ~ [ost %give %rush %twit-feed (flop ole)]~ =- [ost %pass [%peer pax] %e %them ~ `hiss`-] + =+ opt=?~(ole ~ ['since_id' (lutt:twit id.i.ole)]~) + =+ aut=any-auth ?- -.pax - %user (stat-user:auth [(to-sd p.pax)]~ ~) - %home - ?~ ole (stat-home:auth) - =+ opt=['since_id' (lutt:twit id.i.ole)]~ - (stat-home:auth ~ opt) + %user (stat-user:aut [(to-sd p.pax)]~ opt) +:: %home (stat-home:auth ~ opt) == :: ++ to-sd :: parse user name/numb diff --git a/main/app/twitter-auth/core.hook b/main/app/twitter-auth/core.hook index 2266ebddf..e1ed5b426 100644 --- a/main/app/twitter-auth/core.hook +++ b/main/app/twitter-auth/core.hook @@ -3,24 +3,31 @@ !: |_ [hide vat=wain] ++ prompts - `(list cord)`~['App token: ' 'App secret: ' 'User token: ' 'User secret: ' ''] + ^- wain + :~ 'User: ' + '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)) `+>.$ + ?. =(5 (lent vat)) `+>.$ %.(+< (add-exit ,_`+>.$)) :: ++ part =. vat (flop vat) :: put into order of entry - ?. ?=([@ @ @ @ ~] vat) + ?. ?=([@ @ @ @ @ ~] vat) ~|([%keys-missing vat] !!) - =+ =< aut=[[ctok csec] atok asec] - `[ctok=cord csec=cord atok=cord asec=cord ~]`vat + =+ =< aut=[acc %auth [ctok csec] atok asec] + `[acc=span ctok=cord csec=cord atok=cord asec=cord ~]`vat |= ost=bone :_ ~ :^ ost %pass /out - [%g %mess serv our %twit-do !>([%auth aut])] + [%g %mess serv our %twit-do !>(aut)] :: ++ poke--args (listen-in . (add-nice ,_`.)) ++ serv [our /twit] diff --git a/main/app/twitter-auth/hoontap-keys.txt b/main/app/twitter-auth/hoontap-keys.txt index ed380f2d9..7b938bffb 100644 --- a/main/app/twitter-auth/hoontap-keys.txt +++ b/main/app/twitter-auth/hoontap-keys.txt @@ -1,3 +1,4 @@ +hoontap AP3G1t8ki6rPzeeAqdWCTw03F VV784LPwZSaAxtF16RWWTnST4F85BHN8VqQKNyv7MprCkA0xZD 2821727326-RZGXSeTn7hCFQfJqR0ViivM3YYpu2O1M71gelBl diff --git a/main/app/twitter-feed/core.hook b/main/app/twitter-feed/core.hook index 9120b7e73..85d72c16f 100644 --- a/main/app/twitter-feed/core.hook +++ b/main/app/twitter-feed/core.hook @@ -12,7 +12,10 @@ ++ rens |=(stat rose/[": " `~]^~[leaf/"{} @{(trip who)}" leaf/(trip txt)]) ++ peer ,_`. -++ poke--args (add-subs [[our /twit] our /home] ,_`.) +++ poke--args + |= [ost=bone his=ship who=span ~] + %.(+< (add-subs [[our /twit] our /user/[who]] ,_`+>.$)) +:: ++ posh-twit-feed (args-into-gate . |=(a=(list stat) tang/(turn a rens))) :: ++ pour |*([ost=@ * sih=[@ ^]] :_(+>.$ [ost %give +.sih]~)) diff --git a/main/sur/twitter/core.hook b/main/sur/twitter/core.hook index 46e387000..1780f2404 100644 --- a/main/sur/twitter/core.hook +++ b/main/sur/twitter/core.hook @@ -1,5 +1,6 @@ |% -++ twit-do +++ twit-do ,[p=span q=command] :: user and action +++ command :: poke action $% [%auth p=keys] :: set API keys [%post p=@uvI q=cord] :: post a tweet ==