mirror of
https://github.com/octoleo/telegram-bot-bash.git
synced 2024-12-27 20:44:53 +00:00
start of ready to use scripts
This commit is contained in:
parent
85ee75705a
commit
e6223b6645
@ -11,7 +11,7 @@
|
||||
# This file is public domain in the USA and all free countries.
|
||||
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
|
||||
#
|
||||
#### $$VERSION$$ v1.2-dev2-28-g5b94265
|
||||
#### $$VERSION$$ v1.2-dev2-29-g85ee757
|
||||
#
|
||||
# Exit Codes:
|
||||
# - 0 success (hopefully)
|
||||
@ -560,7 +560,8 @@ sendJsonResult(){
|
||||
if [ "${res}" != "" ]; then
|
||||
BOTSENT[ERROR]="$(JsonGetValue '"error_code"' <<< "${1}")"
|
||||
BOTSENT[DESCRIPTION]="$(JsonGetString '"description"' <<< "${1}")"
|
||||
BOTSENT[RETRY]="$(JsonGetValue '"parameters","retry_after"' <<< "${1}")"
|
||||
grep -qs -F '"parameters","retry_after"' <<< "${1}" &&\
|
||||
BOTSENT[RETRY]="$(JsonGetValue '"parameters","retry_after"' <<< "${1}")"
|
||||
else
|
||||
BOTSENT[OK]="false"
|
||||
BOTSENT[ERROR]="999"
|
||||
|
76
bin/send_message.sh
Executable file
76
bin/send_message.sh
Executable file
@ -0,0 +1,76 @@
|
||||
#!/bin/bash -
|
||||
#===============================================================================
|
||||
#
|
||||
# FILE: send_message.sh
|
||||
#
|
||||
# USAGE: send_message.sh [-h|--help] [format] "CHAT[ID]" "message ...." [debug]
|
||||
#
|
||||
# DESCRIPTION: send a message to the given user/group
|
||||
#
|
||||
# OPTIONS: format - normal, markdown, html (optional)
|
||||
# CHAT[ID] - ID number of CHAT
|
||||
# message - message to send in specified format
|
||||
# if no format is givern send_message() format is used
|
||||
#
|
||||
# -h - display short help
|
||||
# --help - this help
|
||||
#
|
||||
# Set BASHBOT_HOME to your installation directory
|
||||
#
|
||||
# LICENSE: WTFPLv2 http://www.wtfpl.net/txt/copying/
|
||||
# AUTHOR: KayM (gnadelwartz), kay@rrr.de
|
||||
# CREATED: 16.12.2020 11:34:27
|
||||
#
|
||||
#### $$VERSION$$ v1.2-dev2-29-g85ee757
|
||||
#===============================================================================
|
||||
|
||||
# set where your bashbot lives
|
||||
# shellcheck disable=SC1090
|
||||
BASHBOT_HOME="${BASHBOTHOME:-../}"
|
||||
|
||||
# check for botconfig.jssh
|
||||
if [ ! -r "${BASHBOT_HOME}/botconfig.jssh" ]; then
|
||||
echo "No bashbot config file in ${BASHBOT_HOME}"
|
||||
exit 3
|
||||
fi
|
||||
|
||||
# parse args
|
||||
SEND="send_message"
|
||||
case "$1" in
|
||||
"nor*"|"tex*")
|
||||
SEND="send_normal_message"
|
||||
shift
|
||||
;;
|
||||
"mark"*)
|
||||
SEND="send_markdownv2_message"
|
||||
shift
|
||||
;;
|
||||
"html")
|
||||
SEND="send_html_message"
|
||||
shift
|
||||
;;
|
||||
'')
|
||||
echo "missing missing arguments"
|
||||
;&
|
||||
"-h"*)
|
||||
echo "usage: send_message [-h|--help] [format] "CHAT[ID]" "message ...." [debug]"
|
||||
exit 1
|
||||
;;
|
||||
'--h'*)
|
||||
sed -n '3,/###/p' <"$0"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
if [[ "$1" == *[!0-9-]* ]]; then
|
||||
echo "CHAT[ID] is not a number! use: $0 -h for help"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
# source bashbot and send message
|
||||
source "${BASHBOT_HOME}/bashbot.sh" source "$3"
|
||||
"${SEND}" "$1" "$2"
|
||||
|
||||
# output result
|
||||
jssh_printDB "BOTSENT" | sort -r
|
||||
|
@ -29,6 +29,8 @@ Have FUN!
|
||||
├── commands.sh # command dispatcher - DO NOT EDIT!
|
||||
├── JSON.sh # bashbots JSON parser, see https://github.com/dominictarr/JSON.sh
|
||||
│
|
||||
├── bin # some ready to use scripts scripts, e.g. to send a message
|
||||
│
|
||||
├── scripts # place your bashbot interactive and background scripts here
|
||||
│ └── interactive.sh.clean # interactive script template for new scripts
|
||||
│
|
||||
@ -298,5 +300,5 @@ send_action "${CHAT[ID]}" "action"
|
||||
#### [Prev Create Bot](1_firstbot.md)
|
||||
#### [Next Advanced Usage](3_advanced.md)
|
||||
|
||||
#### $$VERSION$$ v1.2-dev2-5-gda7a3f1
|
||||
#### $$VERSION$$ v1.2-dev2-29-g85ee757
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user