Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mitsugu/nostk
Nostr client written in Go
https://github.com/mitsugu/nostk
Last synced: 3 months ago
JSON representation
Nostr client written in Go
- Host: GitHub
- URL: https://github.com/mitsugu/nostk
- Owner: mitsugu
- License: mit
- Created: 2023-07-09T10:48:25.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-05-12T01:25:25.000Z (6 months ago)
- Last Synced: 2024-05-12T02:27:24.744Z (6 months ago)
- Language: Go
- Size: 97.7 KB
- Stars: 4
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: License.jp.md
Awesome Lists containing this project
- awesome-nostr-japan - nostk - nostr向けcliアプリケーション by [mitsugu oyama (orzbruford)](https://github.com/mitsugu) (CLI Clients)
README
nostk
========
Implementing a CLI client to use [Nostr Protocol](https://github.com/nostr-protocol/nostr).### Develop Environment
* Ubuntu 23.04 and later
* Go Language 1.22.4 and later### Features
* Initializing the nostk environment
* Generating a key pair
* Edit your contact list
* Edit custom emoji list
* Edit relay list
* Publish relay list
* Edit profile
* Publish profile
* Display home timeline ([kind 1](https://github.com/nostr-protocol/nips/blob/master/01.md#kinds))
* Display your's note ([kind 1](https://github.com/nostr-protocol/nips/blob/master/01.md#kinds))
* Publish Note ([kind 1](https://github.com/nostr-protocol/nips/blob/master/01.md#kinds))
* Publish Note to some user (like Mension, [kind 1](https://github.com/nostr-protocol/nips/blob/master/01.md#kinds))
* Content warning
* Hash tags### ToDo
* Re-note
* Message citations
* Log viewer (Stoped development)
* Any more### Requirements
* [nbd-wtf / go-nostr](https://github.com/nbd-wtf/go-nostr)
* Some kind of text editor
* Setting $EDITOR environment variable### Setup
#### Install tools
1. Install [git](https://www.git-scm.com/)
2. Install [golang](https://go.dev/)#### Install nostk:
##### Windows
```command.com
SETX EDITOR=
go install github.com/mitsugu/nostk@
```##### Ubuntu and maybe other distribution
For bash
```bash
echo 'export EDITOR=vim' >> ~/.bashrc
go install github.com/mitsugu/nostk@
```#### Placement of config.json
IF config.json NOT FOUND IN .nostk DIRECTORY, EXECUTE THE FOLLOWING.
1. Download [config.json](https://raw.githubusercontent.com/mitsugu/nostk/main/config.json)
2. Move config.json to "$HOME/.nostk" directory
3. Adjust defaultReadNo, multiplierReadRelayWaitTime, and defaultContentWarning in config.json to your liking.#### Setting nostk:
1. nostk init (must)
2. nostk genkey (must)
3. nostk editRelays (must)
4. nostk editContacts (must)
5. nostk editProfile (should \*)
6. nostk pubProfile (should \*)
7. nostk editEmoji (Optional)
8. nostk pubRelays (Optional)\* Unless there is a special reason, it is recommended to use a web app such as [nostter](https://nostter.app/home) instead of nostk.
### Usage
#### Display help documanets
``` bash
nostk helpnostk -h
nostk --help
nostk
```#### Init nostk
``` bash
nostk init
```#### Ganerate Key Pair
``` bash
nostk genkey
```#### Edit contact list
``` bash
nostk editContacts
```#### Edit custom emoji
``` bash
nostk editEmoji
```#### Edit relay list
``` bash
nostk editRelays
```#### Publish relay list
``` bash
nostk pubRelays
```#### Edit profile
``` bash
nostk editProfile
```#### Publish profile
``` bash
nostk pubProfile
```#### Publish message
``` bash
nostk pubMessage [reason of content warning]nostk pubMessage < (ps)
(ps) | nostk pubMessage
```#### Publish message to
``` bash
nostk pubMessageTo
```#### Display home timeline (kind 1, default uninclude content warning)
``` bash
nostk catHome [number]
```#### Display MSFW timeline (kind 1, default include content warning)
``` bash
nostk catNSFW [number]
```#### Display your's note (kind 1)
``` bash
nostk catSelf [number]
```#### Display specified event
``` bash
nostk catEvent
```#### Remove specified event (Test implementation)
``` bash
nostk removeEvent [reason]
```#### Custom emoji reaction (Test implementation)
``` bash
nostk emojiReaction
```### About content warning note
The catHome subcommand does not directly display notes with content warnings.The corresponding note will be printed to indicate that it is a content warning note, the reason will be displayed if a reason is set, and the event ID of the note will also be displayed.
To display a content warning note, run the catEvent subcommand by specifying the note's Event ID in hex.### .vimrc sample code to call from vim
``` vimscript
" Usage
" 1. Write content current buffer
" 2. execute next command on command-line
" : NPublishMessage [reason]
" If reason is given as an argument,
" it will be published as a content warning note.
"
command! -nargs=? NPublishMessage call Pubmessage()
function Pubmessage(...)
if a:0 >= 1
let l:buffer_contents = join(getline(1, '$'), "\n")
let l:command = "nostk pubMessage \"" . l:buffer_contents . "\" " . a:1
let l:command_output = system(l:command)
echo l:command_output
else
w ! nostk pubMessage
end
endfunction
`````` vimscript
" Usage
" execute next command on command-line
" : NCathome [number]
" If you pass number as an argument,
" it will ask the relay to subscribe to number notes.
"
command! -nargs=? NCathome call Cathome()
function! Cathome(...)
if a:0 >= 1
let l:command = "nostk catHome " . a:1 . " | jq '.'"
let l:command_output = system(l:command)
call append('$', split(l:command_output, "\n"))
else
r! nostk catHome | jq '.'
end
set ft=json
endfunction
`````` vimscript
" Usage
" execute next command on command-line
" : NCatnsfw [number]
" If you pass number as an argument,
" it will ask the relay to subscribe to number notes.
"
command! -nargs=? NCatnsfw call Catnsfw()
function! Catnsfw(...)
if a:0 >= 1
let l:command = "nostk catNSFW " . a:1 . " | jq '.'"
let l:command_output = system(l:command)
call append('$', split(l:command_output, "\n"))
else
r! nostk catNSFW | jq '.'
end
set ft=json
endfunction
`````` vimscript
" Usage
" execute next command on command-line
" : NCatself [number]
" If you pass number as an argument,
" it will ask the relay to subscribe to number notes.
"
command! -nargs=? NCatself call Catself()
function! Catself(...)
if a:0 >= 1
let l:command = "nostk catSelf " . a:1 . " | jq '.'"
let l:command_output = system(l:command)
call append('$', split(l:command_output, "\n"))
else
r! nostk catSelf | jq '.'
end
set ft=json
endfunction
`````` vimscript
" Usage
" execute next command on command-line
" : NRemoveEvent [reason]
" Event Id : Specify the Event ID to be deleted
" reason : Specify the reason for deletion. Reason is optional.
"
command! -nargs=1 NRemoveEvent call Removeevent()
function! Removeevent(...)
let l:command = "nostk removeEvent "
for arg in a:000
let l:command .= arg
endfor
let l:command_output = system(l:command)
echo l:command_output
endfunction
`````` vimscript
" Usage
" 1. Move the cursor to the EVENT ID of the post you want to react to
" in the nostk log DISPLAYED IN THE CURRENT BUFFER.
" 2. execute next command on command-line
" : NEmojireaction
" custom emoji short code : Specify a custom emoji shortcode
"
command! -nargs=1 NEmojireaction call Emojireaction()
function! Emojireaction(stremoji)
let l:topline = line('.')
let l:btmline = l:topline + 3
let l:lines = getline(l:topline, l:btmline)
let l:lines_text = join(lines, "\n")
try
let l:json_data = json_decode("{" . l:lines_text . "}}")
let l:keys = keys(l:json_data)
let l:eventId = l:keys[0]
let l:data = l:json_data[l:eventId]
let l:pubkey = l:data.pubkey
catch
echoerr "Invalid JSON in selected range."
endtry
let l:cmd = 'nostk emojiReaction ' . l:eventId . " " . l:pubkey . ' "' . a:stremoji . '"'
let l:command_output = system(l:cmd)
echo l:command_output
endfunction
```