Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function run_rank()
- {
- unset numero
- numero="${message_from_id[$id]}"
- grupo=$(echo ${message_chat_id[$id]}|sed 's/-//')
- cat_=$(cat /etc/ShellBot/Usuarios/${grupo}/ranking |grep "$numero"| cut -d'|' -f2)
- if [[ $cat_ = "" ]]; then
- echo "$numero|0" >> /etc/ShellBot/Usuarios/${grupo}/ranking
- else
- result=$(echo $((1+$cat_)))
- sed -i "s/$numero|$cat_/$numero|$result/g" /etc/ShellBot/Usuarios/${grupo}/ranking
- fi
- }
- function ranking()
- {
- local msg
- chamada=(${message_text[$id]})
- verifica_nivel "@${message_from_username[$id]}"
- if [[ ${chamada[0]} = "/zerar" ]]; then
- case $nivel in
- creator) rm /etc/ShellBot/Usuarios/${grupo}/ranking
- msg+="<b>Ranking restaurado!</b>"
- ;;
- member|false|true) msg+="<b>Desculpe, esse comando só pode ser utilizado pelo criador do grupo!</b>"
- ;;
- esac
- elif [[ ${chamada[0]} = "/ranking" ]]; then
- case $nivel in
- true|false|creator)
- local msg
- grupo=$(echo ${message_chat_id[$id]}|sed 's/-//')
- echo "$(cat Usuarios/$grupo/ranking|awk -F'|' '{print $1" - "$2}'| sort -t'-' -nrk2)" > /etc/ShellBot/Usuarios/${grupo}/semi_ranking
- a=($(cat /etc/ShellBot/Usuarios/${grupo}/semi_ranking|cut -d'-' -f1))
- for((i=0; i<${#a[@]}; i++)); do
- nome=$(cat Usuarios/$grupo/${a[$i]}|cut -d'|' -f3)
- sed -i "s|${a[$i]}|<a href=\"tg://user?id=${a[$i]}\">${nome}</a>|g" /etc/ShellBot/Usuarios/${grupo}/semi_ranking
- done
- cd=$(cat /etc/ShellBot/Usuarios/${grupo}/semi_ranking)
- msg+="<b>RANKING</b>\n$(cat /etc/ShellBot/Usuarios/${grupo}/semi_ranking|sed 's/^/\\n/')\n\nPowered by @BrIsBr_BoT"
- #ShellBot.sendMessage --chat_id ${message_chat_id[$id]} --text "$(echo -e $msg)" --parse_mode html
- ;;
- *) msg+="<b>Desculpe você não é administrador!</b>"
- ;;
- esac
- fi
- ShellBot.sendMessage --chat_id ${message_chat_id[$id]} --text "$(echo -e $msg)" --parse_mode html
- }
- # o run_rank fica sendo chamado a todo momento
- # o ranking so e chamado quando invocado /ranking ou /zerar
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement