Upgrade to Pro — share decks privately, control downloads, hide ads and more …

思考の速さで使うクライアント ~vimクライアント作ってみた~

Hakkadaikon
February 21, 2024

思考の速さで使うクライアント ~vimクライアント作ってみた~

Bluesky勉強会 #3で発表したLT
https://428lab.connpass.com/event/310260/

Hakkadaikon

February 21, 2024
Tweet

More Decks by Hakkadaikon

Other Decks in Programming

Transcript

  1. 自己紹介 1/3 自己紹介で3枚も使うだと…? 名前 : 発火大根 Bluesky歴 : 9か月ちょい(2023/5/1開始) 職業

    : インフラエンジニア(コードも書くぞい) よくいるSNS : Nostr 趣味 : Nostr 最近ハマっていること : Nostr 好きなエディタ : ???
  2. 自己紹介 2/3 色々やってます。 主に四谷ラボの名前を借りてます。 ▪登壇 2023/8/3 [四谷ラボ] Nostr勉強会 #3 LT

    2023/9/2 [四谷ラボ] Bluesky勉強会 #2 企画/司会/LT 2023/12/8 [四谷ラボ] 新時代の分散型SNS勉強会 運営 2023/12/13 [ゴリラ.vim] ゴリラ.vim #29 LT 2024/2/10 [ゴリラ.vim/四谷ラボ] ゴリラ.vim #30 企画/ライブコーディング ▪本 Hello Nostr! Yo Bluesky! 分散SNSの最前線 2記事寄稿
  3. function! s:convert_feed_to_row(feed) abort return { ¥"text": a:feed["post"]["record"]["text"], ¥"user": { ¥

    "name": a:feed["post"]["author"]["displayName"], ¥ "screen_name": a:feed["post"]["author"]["handle"], ¥ "url": "https://bsky.social/" . a:feed["post"]["author"]["handle"], ¥}, ¥"metadata": { ¥ "created_at_str": a:feed["post"]["record"]["createdAt"], ¥}, ¥"reactions": [ ¥ { ¥ "action": " ", ¥ "count": a:feed["post"]["likeCount"], ¥ } ¥] ¥} endfunction function! s:main() abort let s:winid = s:create_buffer() let s:feed_array = s:get_feed_array() let s:rows = [] for feed in s:feed_array if !has_key(feed, "post") continue endif let s:row = s:convert_feed_to_row(feed) let s:rows += [s:row] call s:draw(s:winid, s:rows) endfor endfunction call s:main() " bsky_client.vim " " use ui.vim: https://github.com/skanehira/ui.vim " use indigo: https://github.com/bluesky-social/indigo let s:cli_path = "./indigo/gosky" let s:auth_path = "./auth.json" let s:pds_host = "https://bsky.social" function! s:set_env() abort let s:env_path ="./env.sh" call system(s:env_path) endfunction function! s:get_feed_array() abort let l:feed_cmd = s:cli_path . " --pds-host=" . s:pds_host . " --auth=" . s:auth_path . " bsky get-feed --raw" let l:feed_json = system(feed_cmd) let l:feed_json_array = '[' . substitute(l:feed_json, '}¥n{', '},{', 'g') . ']' let l:decoded_feed = json_decode(l:feed_json_array) return l:decoded_feed endfunction function! s:create_buffer() silent noautocmd split __Nostr_TL__ setlocal buftype=nofile bufhidden=wipe noswapfile setlocal wrap nonumber signcolumn=no filetype=markdown wincmd p return bufwinid("__Nostr_TL__") endfunction function! s:draw(winid, rows) abort call win_execute(a:winid, 'setlocal modifiable', 1) call win_execute(a:winid, 'normal! G', 1) call win_gotoid(a:winid) call ui#chat#draw(a:winid, a:rows) call win_execute(a:winid, 'setlocal nomodifiable nomodified', 1) endfunction ソースコード(vimscript 75L)
  4. Indigoの”gosky”で色々できる USAGE: gosky bsky command [command options] [arguments...] COMMANDS: follow

    create a follow relationship (auth required) list-follows print list of follows for account post create a post record get-feed fetch bsky feed like create bsky ‘like’ record delete-post actor-get-suggestions notifs fetch bsky notifications (requires auth) help, h Shows a list of commands or help for one command