- sending action can now print event id (created for send) to stdout - for an example on how to use it, see `tests/test-delete.sh` ``` --print-event-id If set and listening, then 'matrix-commander' will print also the event id for each received message or other received event. If set and sending, then 'matrix-commander' will print the event id of the sent message or the sent object (audio, file, event) to stdout. Other information like room id and reference to what was sent will be printed too. For sending this is useful, if after sending the user wishes to perform further operations on the sent object, e.g. redacting/deleting it after an expiration time, etc. ```pull/82/head v2.37.0
parent
2265e87a82
commit
1cf3d09a72
4 changed files with 330 additions and 0 deletions
@ -0,0 +1,25 @@ |
||||
#!/bin/bash |
||||
|
||||
# |
||||
# # on PC where PyPi package is to be created |
||||
# python3 -m pip install --upgrade build # install necessary build packages |
||||
# python3 -m pip install --upgrade twine # install necessary build packages |
||||
# rm dist/* # cleanup |
||||
# nano setup.cfg # increment version number |
||||
# python3 -m build # build PyPi package |
||||
# python3 -m twine upload dist/* # upload PyPi package, use __token__ as user |
||||
# |
||||
# # on PC where to install |
||||
# sudo apt install libolm-dev |
||||
# pip3 install matrix-commander |
||||
# export PATH=$PATH:/home/user/.local/bin |
||||
# matrix-commander --help # test it |
||||
# |
||||
|
||||
# prepare-commit, including version increase in setup.cfg |
||||
rm dist/* # cleanup |
||||
python3 -m build |
||||
ls -l dist/* |
||||
# publish |
||||
# echo "Use __token__ as user." && |
||||
# python3 -m twine upload dist/* |
@ -0,0 +1,6 @@ |
||||
#!/bin/bash |
||||
|
||||
# see also pypi-package-1-create.sh script which creates the PyPi release |
||||
|
||||
echo "Use __token__ as user." |
||||
python3 -m twine upload dist/* |
@ -0,0 +1,255 @@ |
||||
#!/bin/bash |
||||
|
||||
echo "Welcome!" |
||||
echo "The script outlines the rough workflow" |
||||
echo "" |
||||
echo "You have written some code? Let's publish it." |
||||
|
||||
# https://askubuntu.com/questions/1705/how-can-i-create-a-select-menu-in-a-shell-script |
||||
PS3='Please enter your choice: ' |
||||
OPT1="git pull # get the latest from Github" |
||||
OPTC="Continue" |
||||
OPTQ="Quit" |
||||
options=("$OPT1" "$OPTC" "$OPTQ") |
||||
select opt in "${options[@]}"; do |
||||
if [ "${REPLY,,}" == "c" ]; then opt="$OPTC"; fi |
||||
if [ "${REPLY,,}" == "q" ]; then opt="$OPTQ"; fi |
||||
case ${opt} in |
||||
"$OPT1") |
||||
OPTE=${opt%%#*} # remove everything after first # |
||||
echo "Performing: $OPTE" |
||||
$OPTE |
||||
break |
||||
;; |
||||
"$OPTC") |
||||
echo "On to next step." |
||||
break |
||||
;; |
||||
"$OPTQ" | "quit") |
||||
echo "Quitting program." |
||||
exit 0 |
||||
;; |
||||
*) echo "invalid option $REPLY" ;; |
||||
esac |
||||
done |
||||
|
||||
PS3='Please enter your choice: ' |
||||
OPT1="tests/test-send.py # run this testcase" |
||||
OPT2="tests/test-delete.sh # run this testcase" |
||||
OPT3="tests/test-event.sh # run this testcase" |
||||
OPT4="tests/test-rest.sh # run this testcase" |
||||
OPT5="tests/test-setget.sh # run this testcase" |
||||
OPT6="tests/test-upload.sh # run this testcase" |
||||
OPTC="Continue" |
||||
OPTQ="Quit" |
||||
options=("$OPT1" "$OPT2" "$OPT3" "$OPT4" "$OPT5" "$OPT6" "$OPTC" "$OPTQ") |
||||
select opt in "${options[@]}"; do |
||||
if [ "${REPLY,,}" == "c" ]; then opt="$OPTC"; fi |
||||
if [ "${REPLY,,}" == "q" ]; then opt="$OPTQ"; fi |
||||
case ${opt} in |
||||
"$OPT1" | "$OPT2" | "$OPT3" | "$OPT4" | "$OPT5" | "$OPT6") |
||||
OPTE=${opt%%#*} # remove everything after first # |
||||
echo "Performing: $OPTE" |
||||
$OPTE |
||||
continue |
||||
;; |
||||
"$OPTC") |
||||
echo "On to next step." |
||||
break |
||||
;; |
||||
"$OPTQ") |
||||
echo "Quitting program." |
||||
exit 0 |
||||
;; |
||||
*) echo "invalid option $REPLY" ;; |
||||
esac |
||||
done |
||||
|
||||
PS3='Please enter your choice: ' |
||||
OPT1="scripts/update-1-version.sh # increment major version number" |
||||
OPT2="scripts/update-1-version.sh --minor # increment minor version number; this skips Actions workflow" |
||||
OPT3="scripts/update-2-help.py # update help file" |
||||
OPT4="scripts/update-3-readme.py # update README.md file" |
||||
OPT5="scripts/lintmc.sh # lint and beautify main file" |
||||
OPT6="scripts/pypi-package-1-create.sh # create PyPi release" |
||||
OPT7="scripts/pypi-package-2-publish.sh # optionally publish PyPi release; maybe skip this for minor versions; skip this if Actions workflow is preferred" |
||||
OPTC="Continue" |
||||
OPTQ="Quit" |
||||
options=("$OPT1" "$OPT2" "$OPT3" "$OPT4" "$OPT5" "$OPT6" "$OPT7" "$OPTC" "$OPTQ") |
||||
select opt in "${options[@]}"; do |
||||
if [ "${REPLY,,}" == "c" ]; then opt="$OPTC"; fi |
||||
if [ "${REPLY,,}" == "q" ]; then opt="$OPTQ"; fi |
||||
case ${opt} in |
||||
"$OPT1" | "$OPT2" | "$OPT3" | "$OPT4" | "$OPT5" | "$OPT6" | "$OPT7") |
||||
OPTE=${opt%%#*} # remove everything after first # |
||||
echo "Performing: $OPTE" |
||||
$OPTE |
||||
continue |
||||
;; |
||||
"$OPTC") |
||||
echo "On to next step." |
||||
break |
||||
;; |
||||
"$OPTQ") |
||||
echo "Quitting program." |
||||
exit 0 |
||||
;; |
||||
*) echo "invalid option $REPLY" ;; |
||||
esac |
||||
done |
||||
|
||||
PS3='Please enter your choice: ' |
||||
OPT1="git add dist/ # must do this! commit -a will not include them" |
||||
OPT2="git status # what is the current status" |
||||
OPTC="Continue" |
||||
OPTQ="Quit" |
||||
options=("$OPT1" "$OPT2" "$OPTC" "$OPTQ") |
||||
select opt in "${options[@]}"; do |
||||
if [ "${REPLY,,}" == "c" ]; then opt="$OPTC"; fi |
||||
if [ "${REPLY,,}" == "q" ]; then opt="$OPTQ"; fi |
||||
case ${opt} in |
||||
"$OPT1" | "$OPT2") |
||||
OPTE=${opt%%#*} # remove everything after first # |
||||
echo "Performing: $OPTE" |
||||
$OPTE |
||||
continue |
||||
;; |
||||
"$OPTC") |
||||
echo "On to next step." |
||||
break |
||||
;; |
||||
"$OPTQ") |
||||
echo "Quitting program." |
||||
exit 0 |
||||
;; |
||||
*) echo "invalid option $REPLY" ;; |
||||
esac |
||||
done |
||||
|
||||
PS3='Please enter your choice: ' |
||||
OPT1="git commit -a # alternative 1 for commit" |
||||
OPT2="git commit # alternative 2 for commit" |
||||
OPT3="git commit -a -m 'release: v$(cat VERSION)' # alternative 3 for commit; being lazy" |
||||
OPTC="Continue" |
||||
OPTQ="Quit" |
||||
options=("$OPT1" "$OPT2" "$OPT3" "$OPTC" "$OPTQ") |
||||
select opt in "${options[@]}"; do |
||||
if [ "${REPLY,,}" == "c" ]; then opt="$OPTC"; fi |
||||
if [ "${REPLY,,}" == "q" ]; then opt="$OPTQ"; fi |
||||
case ${opt} in |
||||
"$OPT1" | "$OPT2" | "$OPT3") |
||||
OPTE=${opt%%#*} # remove everything after first # |
||||
echo "Performing: $OPTE" |
||||
$OPTE |
||||
break |
||||
;; |
||||
"$OPTC") |
||||
echo "On to next step." |
||||
break |
||||
;; |
||||
"$OPTQ") |
||||
echo "Quitting program." |
||||
exit 0 |
||||
;; |
||||
*) echo "invalid option $REPLY" ;; |
||||
esac |
||||
done |
||||
|
||||
PS3='Please enter your choice: ' |
||||
OPT1="scripts/update-4-tag.sh # create new annotated tag" |
||||
OPTC="Continue" |
||||
OPTQ="Quit" |
||||
options=("$OPT1" "$OPTC" "$OPTQ") |
||||
select opt in "${options[@]}"; do |
||||
if [ "${REPLY,,}" == "c" ]; then opt="$OPTC"; fi |
||||
if [ "${REPLY,,}" == "q" ]; then opt="$OPTQ"; fi |
||||
case ${opt} in |
||||
"$OPT1") |
||||
OPTE=${opt%%#*} # remove everything after first # |
||||
echo "Performing: $OPTE" |
||||
$OPTE |
||||
break |
||||
;; |
||||
"$OPTC") |
||||
echo "On to next step." |
||||
break |
||||
;; |
||||
"$OPTQ") |
||||
echo "Quitting program." |
||||
exit 0 |
||||
;; |
||||
*) echo "invalid option $REPLY" ;; |
||||
esac |
||||
done |
||||
|
||||
PS3='Please enter your choice: ' |
||||
echo "A tag push of major version kicks off the Docker actions workflow on Github." |
||||
echo "A tag push of major version kicks off the PiPy actions workflow on Github." |
||||
echo "Note: a PR does not trigger Github Actions workflows." |
||||
echo "Only pushing a tag kicks off the workflow and only if not a minor version." |
||||
echo "Instead of 2 separate pushes, one can use *annotated* tags and ----follow-tags." |
||||
OPT1="git push --follow-tags # alternative 1; does both push of changes and push of tag" |
||||
OPT2="git push # alternative 2a; 1st push, since there is no tag, no trigger on workflows" |
||||
OPT3="git push origin v'$(cat VERSION)' # alternative 2b; 2nd push, pushing tag" |
||||
OPT4="git push && git push origin v'$(cat VERSION)' # alternative 3; both pushes" |
||||
OPTC="Continue" |
||||
OPTQ="Quit" |
||||
options=("$OPT1" "$OPT2" "$OPT3" "$OPT4" "$OPTC" "$OPTQ") |
||||
select opt in "${options[@]}"; do |
||||
if [ "${REPLY,,}" == "c" ]; then opt="$OPTC"; fi |
||||
if [ "${REPLY,,}" == "q" ]; then opt="$OPTQ"; fi |
||||
case ${opt} in |
||||
"$OPT1" | "$OPT2" | "$OPT3" | "$OPT4") |
||||
OPTE=${opt%%#*} # remove everything after first # |
||||
echo "Performing: $OPTE" |
||||
$OPTE |
||||
continue |
||||
;; |
||||
"$OPTC") |
||||
echo "On to next step." |
||||
break |
||||
;; |
||||
"$OPTQ") |
||||
echo "Quitting program." |
||||
exit 0 |
||||
;; |
||||
*) echo "invalid option $REPLY" ;; |
||||
esac |
||||
done |
||||
|
||||
PS3='Please enter your choice: ' |
||||
echo "Watch Actions workflows on Github, if any." |
||||
echo "Now double-check if everything is in order." |
||||
OPT1="git tag --list -n --sort=-refname # list tags" |
||||
OPT2="git log --pretty=oneline -n 7 # now it shows tag in commit hash" |
||||
OPT3="git log -1 --pretty=%B # details of last commit" |
||||
OPT4="git tag --list -n20 $(git describe) # details of last tag" |
||||
OPT5="git status # list status" |
||||
OPTC="Continue" |
||||
OPTQ="Quit" |
||||
options=("$OPT1" "$OPT2" "$OPT3" "$OPT4" "$OPT5" "$OPTC" "$OPTQ") |
||||
select opt in "${options[@]}"; do |
||||
if [ "${REPLY,,}" == "c" ]; then opt="$OPTC"; fi |
||||
if [ "${REPLY,,}" == "q" ]; then opt="$OPTQ"; fi |
||||
case ${opt} in |
||||
"$OPT1" | "$OPT2" | "$OPT3" | "$OPT4" | "$OPT5") |
||||
OPTE=${opt%%#*} # remove everything after first # |
||||
echo "Performing: $OPTE" |
||||
$OPTE |
||||
continue |
||||
;; |
||||
"$OPTC") |
||||
echo "On to next step." |
||||
break |
||||
;; |
||||
"$OPTQ") |
||||
echo "Quitting program." |
||||
exit 0 |
||||
;; |
||||
*) echo "invalid option $REPLY" ;; |
||||
esac |
||||
done |
||||
|
||||
echo "Bye" |
||||
|
||||
exit 0 |
@ -0,0 +1,44 @@ |
||||
#!/bin/bash |
||||
|
||||
# just in case PATH is not set correctly |
||||
PATH=".:./matrix_commander:../matrix_commander:$PATH" |
||||
|
||||
# One may set similar values in the terminal before calling the script. |
||||
# export MC_OPTIONS="-d --room \!...some.room.id:matrix.example.org " |
||||
|
||||
# getting some optional arguments |
||||
if [ "$MC_OPTIONS" != "" ]; then |
||||
echo "Exellent. Variable MC_OPTIONS already set. " \ |
||||
"Using \"$MC_OPTIONS\" as additional options for testing." |
||||
else |
||||
echo "Optionally, set variable \"MC_OPTIONS\" for further options." |
||||
fi |
||||
|
||||
function test1() { |
||||
echo "=== Test 1: send a message, get event id, delete msg ===" |
||||
echo "Watch it in your client, e.g. Element. Messge arrives, message is removed." |
||||
respd=$(matrix-commander -m "Want to get event id for this message." $MC_OPTIONS 2>&1) |
||||
resp=$(echo "$respd" | grep "INFO: ") |
||||
room_id=$(echo $resp | awk -F'"' '{print $4}') |
||||
event_id=$(echo $resp | awk -F'"' '{print $6}') |
||||
echo "room: $room_id" |
||||
echo "event: $event_id" |
||||
matrix-commander --room-delete-content "$room_id" "$event_id" "Just testing." |
||||
} |
||||
|
||||
function test2() { |
||||
echo "=== Test 2: send a message, get event id, delete msg ===" |
||||
echo "Watch it in your client, e.g. Element. Messge arrives, message is removed." |
||||
ev_rm_msg=$(matrix-commander -m "Want to get event id for this message too." --print-event-id $MC_OPTIONS 2>/dev/null) |
||||
echo "stdout was: $ev_rm_msg" |
||||
# shellcheck disable=SC2207 |
||||
out=($(grep -Eo ' |.+' <<<"$ev_rm_msg")) # split by " " |
||||
event_id="${out[0]}" # before first " " |
||||
room_id="${out[1]}" # after first " " and before 2nd " " |
||||
echo "room: $room_id" |
||||
echo "event: $event_id" |
||||
matrix-commander --room-delete-content "$room_id" "$event_id" "Just testing this." |
||||
} |
||||
|
||||
test1 |
||||
test2 |
Loading…
Reference in new issue