Added new option `-T` to add a title to the message.
This commit is contained in:
parent
d29944434a
commit
d687fc2a35
17
telegram
17
telegram
|
@ -12,6 +12,7 @@ PARSE_MODE=""
|
||||||
CODE_MODE=0
|
CODE_MODE=0
|
||||||
CRON_MODE=0
|
CRON_MODE=0
|
||||||
ACTION=""
|
ACTION=""
|
||||||
|
TITLE=""
|
||||||
DISABLE_WEB_PAGE_PREVIEW=false
|
DISABLE_WEB_PAGE_PREVIEW=false
|
||||||
DISABLE_NOTIFICATION=false
|
DISABLE_NOTIFICATION=false
|
||||||
|
|
||||||
|
@ -36,6 +37,7 @@ function help {
|
||||||
echo " -H Enables HTML processing at telegram."
|
echo " -H Enables HTML processing at telegram."
|
||||||
echo " -C Sends text as monospace code. Useful when piping command outputs into this tool."
|
echo " -C Sends text as monospace code. Useful when piping command outputs into this tool."
|
||||||
echo " -r Like -C, but if the first line starts with '+ ', it is specially formatted."
|
echo " -r Like -C, but if the first line starts with '+ ', it is specially formatted."
|
||||||
|
echo " -T <TITLE> Sets a title for the message. Printed in bold text if -M or -H is used."
|
||||||
echo " -l Fetch known chat_ids."
|
echo " -l Fetch known chat_ids."
|
||||||
echo " -R Receive a file sent via telegram."
|
echo " -R Receive a file sent via telegram."
|
||||||
echo " -D Sets disable_web_page_preview parameter to, well, disable the preview for links to webpages."
|
echo " -D Sets disable_web_page_preview parameter to, well, disable the preview for links to webpages."
|
||||||
|
@ -167,7 +169,7 @@ function escapeMarkdown {
|
||||||
echo "$res"
|
echo "$res"
|
||||||
}
|
}
|
||||||
|
|
||||||
while getopts "t:c:i:f:MHCrhlvjnRDN" opt; do
|
while getopts "t:c:i:f:MHCrhlvjnRDNT:" opt; do
|
||||||
case $opt in
|
case $opt in
|
||||||
t)
|
t)
|
||||||
TOKEN="$OPTARG"
|
TOKEN="$OPTARG"
|
||||||
|
@ -216,6 +218,9 @@ while getopts "t:c:i:f:MHCrhlvjnRDN" opt; do
|
||||||
N)
|
N)
|
||||||
DISABLE_NOTIFICATION=true
|
DISABLE_NOTIFICATION=true
|
||||||
;;
|
;;
|
||||||
|
T)
|
||||||
|
TITLE="$OPTARG"
|
||||||
|
;;
|
||||||
?|h)
|
?|h)
|
||||||
help
|
help
|
||||||
;;
|
;;
|
||||||
|
@ -329,6 +334,16 @@ fi
|
||||||
|
|
||||||
log "Text: $TEXT"
|
log "Text: $TEXT"
|
||||||
|
|
||||||
|
if [ -n "$TITLE" ]; then
|
||||||
|
if [ "$PARSE_MODE" == "HTML" ]; then
|
||||||
|
TEXT="<b>$TITLE</b>"$'\n\n'"$TEXT"
|
||||||
|
elif [ "$PARSE_MODE" == "Markdown" ]; then
|
||||||
|
TEXT="*$TITLE*"$'\n\n'"$TEXT"
|
||||||
|
else
|
||||||
|
TEXT="$TITLE"$'\n\n'"$TEXT"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -z "$TEXT" ] && [ -z "$DOCUMENT_FILE" ] && [ -z "$IMAGE_FILE" ]; then
|
if [ -z "$TEXT" ] && [ -z "$DOCUMENT_FILE" ] && [ -z "$IMAGE_FILE" ]; then
|
||||||
echo "Neither text nor image or other file given."
|
echo "Neither text nor image or other file given."
|
||||||
exit 1
|
exit 1
|
||||||
|
|
Loading…
Reference in New Issue