2 # Copyright (C) 2019 Ian Kelling
3 # SPDX-License-Identifier: AGPL-3.0-or-later
7 PATH
="$HOME/.local/bin:$PATH"
9 # usage: rbow [-PROFILE_NAME] [COMMAND]
11 # Wrapper for rainbowstream to use multiple logins and tweet directly
12 # from the command line. PROFILE_NAME can be anything you want.
15 oath
=$HOME/.rainbow_oauth
16 if [[ $1 == -* ]]; then
21 source ~
/src
/rainbowstream
/venv
/bin
/activate
25 # adds a short delay after each send for more reliable operation
26 set force_conservative 1
29 expect -nocase timeout {exit 1} "@*]: "
30 set cmd [lindex $argv 0];
32 expect -nocase timeout {exit 1} "@*]: "
33 # this may not be needed. didnt test
38 expect
$f "$*" ||
{ echo error
: expect failed
; deactivate
; rm -f $f; return 1; }
47 source ~
/src
/diaspy
/venv
/bin
/activate
48 python3 ~
/src
/jan-pona-mute
/jan-pona-mute.py
"$@" ||
{ deactivate
; return 1; }
52 # usage: toot [-PROFILE_NAME] [TOOT_ARGS]
55 source ~
/src
/toot
/venv
/bin
/activate
56 if [[ $1 == -* ]]; then
59 command toot activate
--quiet $account ||
{ deactivate
; return 1; }
61 command toot
"$@" ||
{ deactivate
; return 1; }
66 # post to mastodon + twitter + gnu social post + diaspora
68 # usage: pdt [--dbd] [-m MEDIA_FILE] [-v VIDEO_PATH] [POST]
70 local video media rbow_account gs_account mastodon_account dbd video rbow_arg toot_arg dia_arg gs_arg
71 if [[ $pdttest ]]; then
74 mastodon_account
=iank@hostux.social
78 mastodon_account
=fsf@hostux.social
82 while [[ $1 == -* ]]; do
87 rbow_arg
=" --i $media"
88 toot_arg
="--media $media"
90 gs_arg
="-F media=@$media"
96 mastodon_account
=endDRM@hostux.social
106 if [[ $media ]]; then
107 if [[ ! -e $media ]]; then
108 echo "error: file not found $media"
111 if [[ $media == *\
* ]]; then
112 echo "error: file path contains a space. move it to non-space path"
116 # if we have no argument
118 read -r -p "input PDT text: " input
121 if [[ $
- == *i
* ]]; then
122 echo "About to PDT the following line. Press enter to confirm or ctrl-c to quit:"
128 oath
=$HOME/.rainbow_oauth
134 ln -s ${oath}-$account $oath
135 python3 ~
/src
/video-tweet
/async-upload.py
"$media" "$*"
139 if ! rbow
-$rbow_account t
"$*" $rbow_arg; then
142 if ! toot
-$mastodon_account post
"$*" $toot_arg; then
146 if ! printf "post %s\n" "${dia_arg}$*" | diaspora
; then
150 # https://gnusocial.net/doc/twitterapi
151 if ! curl
-o /dev
/null
-sS -u "$gs_account:$(cat ~/.gnusocial_login-$gs_account)" \
152 $gs_arg -F "status=$*" https
://status.fsf.org
/api
/statuses
/update.xml
; then
155 if (( ${#fails[@]} )); then
156 printf "$(tput setaf 5)█$(tput sgr0)%.0s" $
(eval echo "{1..${COLUMNS:-60}}"); echo
157 echo "FSF ERROR: ${fails[*]} might not have posted" >&2
163 if [[ $pdttest ]]; then
164 mastodon_accounts
=(iank
)
166 mastodon_accounts
=(fsf endDRM
)
171 for repo
in errhandle rainbowstream diaspy jan-pona-mute video-tweet
; do
172 if [[ -e $repo ]]; then
175 git
reset --hard origin
/master
179 git clone https
://vcs.fsf.org
/git
/$repo.git
182 source ~
/src
/errhandle
/err
183 cp ~
/src
/rainbowstream
/rainbowstream
/colorset
/config ~
/.rainbow_config.json
185 if [[ ! -e ~
/.local
/bin
/pip
]]; then
187 wget
-O$tmp https
://bootstrap.pypa.io
/get-pip.py
193 if [[ ! -e ~
/.local
/bin
/virtualenv
]]; then
194 python3
-m pip
install --user virtualenv
197 cd ~
/src
/rainbowstream
198 python3
-m virtualenv
-p python3 venv
199 source venv
/bin
/activate
200 python3
-m pip
install -r requirements.txt
201 python3
-m pip
install -e .
205 # This repo's upstream is https://alexschroeder.ch/cgit/diaspy which is
206 # recommended in the install instructions here:
207 # https://alexschroeder.ch/cgit/jan-pona-mute/about/
209 python3
-m virtualenv
-p python3 venv
210 source venv
/bin
/activate
211 python3
-m pip
install -r requirements.txt
212 python3
-m pip
install -e .
218 python3
-m virtualenv
-p python3 venv
219 source venv
/bin
/activate
220 # pip freeze after a pip install.
221 cat >requirements.txt
<<'EOF'
222 beautifulsoup4==4.8.2
233 python3
-m pip
install -r requirements.txt
237 if [[ ! -s ~
/.config
/jan-pona-mute
/login
]]; then
238 mkdir ~
/.config
/jan-pona-mute
239 account
=fsf@framasphere.org
240 read -r -p "enter the password for $account > " pass
241 # background: format for this found using the save command
242 cat >~
/.config
/jan-pona-mute
/login
<<EOF
249 for account
in dbd fsf
; do
250 if [[ ! -s ~
/.rainbow_oauth-
$account ]]; then
251 printf "$(tput setaf 5)█$(tput sgr0)%.0s" $
(eval echo "{1..${COLUMNS:-60}}");
252 echo "Please login to $account on twitter in your main browser then press enter. After rainbowstream prompt loads, quit with command q"
256 if [[ ! -s ~
/.gnusocial_login-
$account ]]; then
257 printf "$(tput setaf 5)█$(tput sgr0)%.0s" $
(eval echo "{1..${COLUMNS:-60}}");
258 read -r -p "please enter the password for $account@status.fsf.org > " pass
259 touch ~
/.gnusocial_login-
$account
260 chmod 600 ~
/.gnusocial_login-
$account
261 printf "%s\n" "$pass" > ~
/.gnusocial_login-
$account
265 for account
in ${mastodon_accounts[@]}; do
266 if ! toot activate
$account@hostux.social
&>/dev
/null
; then
267 printf "$(tput setaf 5)█$(tput sgr0)%.0s" $
(eval echo "{1..${COLUMNS:-60}}");
268 echo "Please login to $account on https://hostux.social in your main browser then press enter."
270 toot login
-i hostux.social