@@ -117,10 +117,10 @@ readonly _ERR_ARG_='argumento inválido: o argumento não é suportado pelo par
117117readonly _ERR_RULE_ALREADY_EXISTS_=' falha ao definir: o nome da regra já existe.'
118118readonly _ERR_HANDLE_EXISTS_=' erro ao registar: já existe um handle vinculado ao callback'
119119
120- declare -A _BOT_HANDLE_LIST_
121- declare -a _BOT_RULES_LIST_
120+ declare -A _BOT_HANDLE_
121+ declare -a _BOT_RULES_
122122declare -A _BOT_SET_RULE_
123- declare _VAR_INIT_LIST_
123+ declare _VAR_INIT_
124124
125125Json () { local obj=$( jq -Mc " $1 " <<< " ${*:2}" ) ; obj=${obj# \" } ; echo " ${obj% \" } " ; }
126126
@@ -139,7 +139,7 @@ FlagConv()
139139 local var str=$2
140140
141141 while [[ $str =~ \$\{ ([a-z_]+)\} ]]; do
142- [[ ${BASH_REMATCH[1]} == @ (${_VAR_INIT_LIST_ // / |} ) ]] && var=${BASH_REMATCH[1]} [$1 ] || var=
142+ [[ ${BASH_REMATCH[1]} == @ (${_VAR_INIT_ // / |} ) ]] && var=${BASH_REMATCH[1]} [$1 ] || var=
143143 str=${str// ${BASH_REMATCH[0]} / ${! var} }
144144 done
145145
@@ -555,9 +555,9 @@ ShellBot.init()
555555 [[ $function ]] || MessageError API " $_ERR_PARAM_REQUIRED_ " " [-f, --function]"
556556 [[ $data ]] || MessageError API " $_ERR_PARAM_REQUIRED_ " " [-d, --callback_data]"
557557
558- [[ ${_BOT_HANDLE_LIST_ [$data]} ]] && MessageError API " $_ERR_HANDLE_EXISTS_ " ' [-d, --callback_data]'
558+ [[ ${_BOT_HANDLE_ [$data]} ]] && MessageError API " $_ERR_HANDLE_EXISTS_ " ' [-d, --callback_data]'
559559
560- _BOT_HANDLE_LIST_ [$data ]=func:$function ' ' $args
560+ _BOT_HANDLE_ [$data ]=func:$function ' ' $args
561561
562562 return 0
563563 }
@@ -595,9 +595,9 @@ ShellBot.init()
595595 [[ $cmd ]] || MessageError API " $_ERR_PARAM_REQUIRED_ " " [-c, --command]"
596596 [[ $data ]] || MessageError API " $_ERR_PARAM_REQUIRED_ " " [-d, --callback_data]"
597597
598- [[ ${_BOT_HANDLE_LIST_ [$data]} ]] && MessageError API " $_ERR_HANDLE_EXISTS_ " " [-d, --callback_data]"
598+ [[ ${_BOT_HANDLE_ [$data]} ]] && MessageError API " $_ERR_HANDLE_EXISTS_ " " [-d, --callback_data]"
599599
600- _BOT_HANDLE_LIST_ [$data ]=exec:$cmd
600+ _BOT_HANDLE_ [$data ]=exec:$cmd
601601
602602 return 0
603603 }
@@ -628,11 +628,11 @@ ShellBot.init()
628628 done
629629
630630 # Handles (somente-leitura)
631- readonly _BOT_HANDLE_LIST_
631+ readonly _BOT_HANDLE_
632632
633633 [[ $data ]] || return 1 # vazio
634634
635- IFS=' :' read -r flag cmd <<< " ${_BOT_HANDLE_LIST_ [$data]}"
635+ IFS=' :' read -r flag cmd <<< " ${_BOT_HANDLE_ [$data]}"
636636
637637 case $flag in
638638 func) $cmd ;;
@@ -4913,10 +4913,10 @@ _EOF
49134913 rule+=\" continue\" :\" ${continue} \"
49144914
49154915 # Atualiza lista de regras.
4916- _BOT_RULES_LIST_ =${_BOT_RULES_LIST_ # \{\" rule\" : [}
4917- _BOT_RULES_LIST_ =${_BOT_RULES_LIST_ % ]\} }
4918- _BOT_RULES_LIST_ =${_BOT_RULES_LIST_ }${_BOT_RULES_LIST_ : +,} {$rule }
4919- _BOT_RULES_LIST_ ={\" rule\" :[$_BOT_RULES_LIST_ ]}
4916+ _BOT_RULES_ =${_BOT_RULES_ # \{\" rule\" : [}
4917+ _BOT_RULES_ =${_BOT_RULES_ % ]\} }
4918+ _BOT_RULES_ =${_BOT_RULES_ }${_BOT_RULES_ : +,} {$rule }
4919+ _BOT_RULES_ ={\" rule\" :[$_BOT_RULES_ ]}
49204920
49214921 # Registra regra.
49224922 _BOT_SET_RULE_[$name ]=true
@@ -4969,45 +4969,45 @@ _EOF
49694969 [[ $uid ]] || MessageError API " $_ERR_PARAM_REQUIRED_ " " [-u, --update_id]"
49704970
49714971 # Regras (somente-leitura)
4972- readonly _BOT_RULES_LIST_ _BOT_SET_RULE_
4972+ readonly _BOT_RULES_ _BOT_SET_RULE_
49734973
49744974 # Regras
4975- for (( i= 0 ; i < $(jq '.rule| length' <<< $_BOT_RULES_LIST_ ); i++ )) ; do
4976-
4977- rule_source=$( jq -r " .rule[$i ].source" <<< $_BOT_RULES_LIST_ )
4978- rule_line=$( jq -r " .rule[$i ].line" <<< $_BOT_RULES_LIST_ )
4979- rule_name=$( jq -r " .rule[$i ].name" <<< $_BOT_RULES_LIST_ )
4980- action=$( jq -r " .rule[$i ].action" <<< $_BOT_RULES_LIST_ )
4981- action_args=$( jq -r " .rule[$i ].action_args" <<< $_BOT_RULES_LIST_ )
4982- exec=$( jq -r " .rule[$i ].exec" <<< $_BOT_RULES_LIST_ )
4983- message_id=$( jq -r " .rule[$i ].message_id" <<< $_BOT_RULES_LIST_ )
4984- is_bot=$( jq -r " .rule[$i ].is_bot" <<< $_BOT_RULES_LIST_ )
4985- command=$( jq -r " .rule[$i ].command" <<< $_BOT_RULES_LIST_ )
4986- user_id=$( jq -r " .rule[$i ].user_id" <<< $_BOT_RULES_LIST_ )
4987- username=$( jq -r " .rule[$i ].username" <<< $_BOT_RULES_LIST_ )
4988- chat_id=$( jq -r " .rule[$i ].chat_id" <<< $_BOT_RULES_LIST_ )
4989- chat_name=$( jq -r " .rule[$i ].chat_name" <<< $_BOT_RULES_LIST_ )
4990- chat_type=$( jq -r " .rule[$i ].chat_type" <<< $_BOT_RULES_LIST_ )
4991- language=$( jq -r " .rule[$i ].language_code" <<< $_BOT_RULES_LIST_ )
4992- text=$( jq -r " .rule[$i ].text" <<< $_BOT_RULES_LIST_ )
4993- entities_type=$( jq -r " .rule[$i ].entities_type" <<< $_BOT_RULES_LIST_ )
4994- file_type=$( jq -r " .rule[$i ].file_type" <<< $_BOT_RULES_LIST_ )
4995- mime_type=$( jq -r " .rule[$i ].mime_type" <<< $_BOT_RULES_LIST_ )
4996- query_id=$( jq -r " .rule[$i ].query_id" <<< $_BOT_RULES_LIST_ )
4997- query_data=$( jq -r " .rule[$i ].query_data" <<< $_BOT_RULES_LIST_ )
4998- chat_member=$( jq -r " .rule[$i ].chat_member" <<< $_BOT_RULES_LIST_ )
4999- num_args=$( jq -r " .rule[$i ].num_args" <<< $_BOT_RULES_LIST_ )
5000- time=$( jq -r " .rule[$i ].time" <<< $_BOT_RULES_LIST_ )
5001- date=$( jq -r " .rule[$i ].date" <<< $_BOT_RULES_LIST_ )
5002- weekday=$( jq -r " .rule[$i ].weekday" <<< $_BOT_RULES_LIST_ )
5003- user_status=$( jq -r " .rule[$i ].user_status" <<< $_BOT_RULES_LIST_ )
5004- message_status=$( jq -r " .rule[$i ].message_status" <<< $_BOT_RULES_LIST_ )
5005- reply_message=$( jq -r " .rule[$i ].bot_reply_message" <<< $_BOT_RULES_LIST_ )
5006- send_message=$( jq -r " .rule[$i ].bot_send_message" <<< $_BOT_RULES_LIST_ )
5007- forward_message=$( jq -r " .rule[$i ].bot_forward_message" <<< $_BOT_RULES_LIST_ )
5008- reply_markup=$( jq -r " .rule[$i ].bot_reply_markup" <<< $_BOT_RULES_LIST_ )
5009- parse_mode=$( jq -r " .rule[$i ].bot_parse_mode" <<< $_BOT_RULES_LIST_ )
5010- continue=$( jq -r " .rule[$i ].continue" <<< $_BOT_RULES_LIST_ )
4975+ for (( i= 0 ; i < $(jq '.rule| length' <<< $_BOT_RULES_ ); i++ )) ; do
4976+
4977+ rule_source=$( jq -r " .rule[$i ].source" <<< $_BOT_RULES_ )
4978+ rule_line=$( jq -r " .rule[$i ].line" <<< $_BOT_RULES_ )
4979+ rule_name=$( jq -r " .rule[$i ].name" <<< $_BOT_RULES_ )
4980+ action=$( jq -r " .rule[$i ].action" <<< $_BOT_RULES_ )
4981+ action_args=$( jq -r " .rule[$i ].action_args" <<< $_BOT_RULES_ )
4982+ exec=$( jq -r " .rule[$i ].exec" <<< $_BOT_RULES_ )
4983+ message_id=$( jq -r " .rule[$i ].message_id" <<< $_BOT_RULES_ )
4984+ is_bot=$( jq -r " .rule[$i ].is_bot" <<< $_BOT_RULES_ )
4985+ command=$( jq -r " .rule[$i ].command" <<< $_BOT_RULES_ )
4986+ user_id=$( jq -r " .rule[$i ].user_id" <<< $_BOT_RULES_ )
4987+ username=$( jq -r " .rule[$i ].username" <<< $_BOT_RULES_ )
4988+ chat_id=$( jq -r " .rule[$i ].chat_id" <<< $_BOT_RULES_ )
4989+ chat_name=$( jq -r " .rule[$i ].chat_name" <<< $_BOT_RULES_ )
4990+ chat_type=$( jq -r " .rule[$i ].chat_type" <<< $_BOT_RULES_ )
4991+ language=$( jq -r " .rule[$i ].language_code" <<< $_BOT_RULES_ )
4992+ text=$( jq -r " .rule[$i ].text" <<< $_BOT_RULES_ )
4993+ entities_type=$( jq -r " .rule[$i ].entities_type" <<< $_BOT_RULES_ )
4994+ file_type=$( jq -r " .rule[$i ].file_type" <<< $_BOT_RULES_ )
4995+ mime_type=$( jq -r " .rule[$i ].mime_type" <<< $_BOT_RULES_ )
4996+ query_id=$( jq -r " .rule[$i ].query_id" <<< $_BOT_RULES_ )
4997+ query_data=$( jq -r " .rule[$i ].query_data" <<< $_BOT_RULES_ )
4998+ chat_member=$( jq -r " .rule[$i ].chat_member" <<< $_BOT_RULES_ )
4999+ num_args=$( jq -r " .rule[$i ].num_args" <<< $_BOT_RULES_ )
5000+ time=$( jq -r " .rule[$i ].time" <<< $_BOT_RULES_ )
5001+ date=$( jq -r " .rule[$i ].date" <<< $_BOT_RULES_ )
5002+ weekday=$( jq -r " .rule[$i ].weekday" <<< $_BOT_RULES_ )
5003+ user_status=$( jq -r " .rule[$i ].user_status" <<< $_BOT_RULES_ )
5004+ message_status=$( jq -r " .rule[$i ].message_status" <<< $_BOT_RULES_ )
5005+ reply_message=$( jq -r " .rule[$i ].bot_reply_message" <<< $_BOT_RULES_ )
5006+ send_message=$( jq -r " .rule[$i ].bot_send_message" <<< $_BOT_RULES_ )
5007+ forward_message=$( jq -r " .rule[$i ].bot_forward_message" <<< $_BOT_RULES_ )
5008+ reply_markup=$( jq -r " .rule[$i ].bot_reply_markup" <<< $_BOT_RULES_ )
5009+ parse_mode=$( jq -r " .rule[$i ].bot_parse_mode" <<< $_BOT_RULES_ )
5010+ continue=$( jq -r " .rule[$i ].continue" <<< $_BOT_RULES_ )
50115011
50125012 u_message_text=${message_text[$uid]:- ${edited_message_text[$uid]:- ${callback_query_message_text[$uid]:- ${inline_query_query[$uid]:- ${chosen_inline_result_query[$uid]} } } } }
50135013 u_message_id=${message_message_id[$uid]:- ${edited_message_message_id[$uid]:- ${callback_query_message_message_id[$uid]:- ${inline_query_id[$uid]:- ${chosen_inline_result_result_id[$uid]} } } } }
@@ -5259,7 +5259,7 @@ _EOF
52595259
52605260
52615261 # Limpa as variáveis inicializadas.
5262- unset $_VAR_INIT_LIST_ ; _VAR_INIT_LIST_ =
5262+ unset $_VAR_INIT_ ; _VAR_INIT_ =
52635263
52645264 # Se há atualizações.
52655265 [[ $( jq -r ' .result|length' <<< $jq_obj ) -eq 0 ]] && return 0
@@ -5301,7 +5301,7 @@ _EOF
53015301 fi
53025302
53035303 unset -n byref
5304- [[ $var != @ (${_VAR_INIT_LIST_ // / |} ) ]] && _VAR_INIT_LIST_ =${_VAR_INIT_LIST_ : +$_VAR_INIT_LIST_ }${var}
5304+ [[ $var != @ (${_VAR_INIT_ // / |} ) ]] && _VAR_INIT_ =${_VAR_INIT_ : +$_VAR_INIT_ }${var}
53055305 done
53065306
53075307 # Log (thread)
0 commit comments