extend mycommands to use new features

This commit is contained in:
Kay Marquardt (Gnadelwartz) 2020-05-14 15:02:17 +02:00
parent a5975d93c4
commit ac2ec02a98
3 changed files with 65 additions and 10 deletions

View File

@ -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$$ v0.94-dev3-0-geef955a
#### $$VERSION$$ v0.94-dev3-3-ga5975d9
#
# Exit Codes:
# - 0 sucess (hopefully)
@ -431,7 +431,6 @@ event_inline() {
done
}
event_message() {
echo "${MESSAGE[0]}"
local key debug="$1"
# ${MESSAEG[*]} event_message
# shellcheck disable=SC2153
@ -610,6 +609,8 @@ process_message() {
SERVICE[NEWTILE]="${UPD["result",${num},"message","new_chat_title"]}"
SERVICE[NEWPHOTO]="${UPD["result",${num},"message","new_chat_photo"]}"
SERVICE[PINNED]="${UPD["result",${num},"message","pinned_message"]}"
# set SSERVICE to yes if a service message was recieved
[[ "${SERVICE[*]}" =~ ^[[:blank:]]+$ ]] || SERVICE[0]="yes"
# split message in command and args

View File

@ -3,12 +3,12 @@
#
# files: mycommands.sh.dist
#
# this is an out of the box test and example file to show what you can do in mycommands.ah
# this is an out of the box test and example file to show what you can do in mycommands.sh
#
# #### if you start to develop you own bot, use the clean version of this file:
# #### if you start to develop your own bot, use the clean version of this file:
# #### mycommands.clean
#
#### $$VERSION$$ v0.94-dev3-2-gbf8a911
#### $$VERSION$$ v0.94-dev3-3-ga5975d9
#
# uncomment the following lines to overwrite info and help messages
@ -29,11 +29,40 @@ export FILE_REGEX='^/home/user/allowed/.*'
# example: run bashbot over TOR
# export BASHBOT_CURL_ARGS="--socks5-hostname 127.0.0.1:9050"
if [ "$1" != "source" ];then
# your additional bahsbot commands
# set to "yes" and give your bot admin privilegs to remove service messaes from groups
export SILENCER="no"
if [ "$1" = "startbot" ];then
###################
# this function is run once after startup when the first message is recieved
my_startup(){
# send message ito first user on startup
send_normal_message "${CHAT[ID]}" "Hi, you was the first one after startup!"
}
# reminde bot that it was started
touch .mystartup
else
# here we call the function above when the mesage arrives
# things to do only at soure, eg. after startup
[ -f .mystartup ] && rm -f .mystartup && _exec_if_function my_startup
#############################
# your own bashbot commands
# NOTE: command can have @botname attached, you must add * in case tests...
mycommands() {
##############
# a service Message was recieved
# add your own stuff here
if [[ "${SERVICE}" != "" ]]; then
# example: delete every service message
if [ "${SILENCER}" = "yes" ]; then
delete_message "${CHAT[ID]}" "${MESSAGE[ID]}"
fi
fi
case "${MESSAGE}" in
##################
# example commands, replace thm by your own

View File

@ -4,7 +4,7 @@
# files: mycommands.sh.clean
# copy to mycommands.sh and add all your commands and functions here ...
#
#### $$VERSION$$ v0.94-dev3-2-gbf8a911
#### $$VERSION$$ v0.94-dev3-3-ga5975d9
#
##########
@ -27,6 +27,9 @@ export INLINE="0"
# do NOT set to .* as this allow sending files from all locations!
export FILE_REGEX='^/home/user/allowed/.*'
# set to "yes" and give your bot admin privilegs to remove service messaes from groups
export SILENCER="no"
########
# special network setups may require to provide additional ARGS to curl
#
@ -34,11 +37,33 @@ export FILE_REGEX='^/home/user/allowed/.*'
# export BASHBOT_CURL_ARGS="--socks5-hostname 127.0.0.1:9050" # TOR
# export BASHBOT_CURL_ARGS="--socks5-hostname 127.0.0.1" # regular SOCKS
if [ "$1" != "source" ];then
# your additional bahsbot commands
if [ "$1" = "startbot" ];then
# run once after startup when the first message is recieved
my_startup(){
:
}
touch .mystartup
else
# here we call the function above when the mesage arrives
# things to do only at soure, eg. after startup
[ -f .mystartup ] && rm -f .mystartup && _exec_if_function my_startup
#############################
# your own bashbot commands
# NOTE: command can have @botname attached, you must add * in case tests...
mycommands() {
##############
# a service Message was recieved
# add your own stuff here
if [[ "${SERVICE}" != "" ]]; then
# example: delete every service message
if [ "${SILENCER}" = "yes" ]; then
delete_message "${CHAT[ID]}" "${MESSAGE[ID]}"
fi
fi
case "${MESSAGE}" in
##################
# example command, replace them by your own