From 30a72eb853ac18832e8f13360ea43afe30b83957 Mon Sep 17 00:00:00 2001 From: "Kay Marquardt (Gnadelwartz)" Date: Fri, 19 Jun 2020 23:26:52 +0200 Subject: [PATCH] examples for action on user and or chat, e.g. logging --- mycommands.sh | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/mycommands.sh b/mycommands.sh index 0231663..02b1d93 100644 --- a/mycommands.sh +++ b/mycommands.sh @@ -8,7 +8,7 @@ # #### if you start to develop your own bot, use the clean version of this file: # #### mycommands.clean # -#### $$VERSION$$ v0.98-dev-33-g18f0ace +#### $$VERSION$$ v0.98-dev-60-gfa6ad3e # # uncomment the following lines to overwrite info and help messages @@ -82,6 +82,19 @@ else fi fi + # exmaple for actions based on chat or sender + case "${USER[ID]}+${CHAT[ID]}" in + 'USERID+'*) # do something for all messages from USER + printf "%s: U=%s C=%s M=%s\n" "$(date)" "${USER[ID]}" "${CHAT[ID]}" "${MESSAGE}" >>"${DATADIR}/${USER[ID]}.log" + ;;& + *'+CHATID') # do something for all messages from CHAT + printf "%s: U=%s C=%s M=%s\n" "$(date)" "${USER[ID]}" "${CHAT[ID]}" "${MESSAGE}" >>"${DATADIR}/${CHAT[ID]}.log" + ;;& + 'USERID+CHATID') # do something only for messages form USER in CHAT + printf "%s: U=%s C=%s M=%s\n" "$(date)" "${USER[ID]}" "${CHAT[ID]}" "${MESSAGE}" >>"${DATADIR}/${CHAT[ID]}+${USER[ID]}.log" + ;;& + esac + # pre-check admin only commands case "${MESSAGE}" in # must be private, group admin, or botadmin