aboutsummaryrefslogtreecommitdiff
path: root/operators/callback_help.zsh
blob: e1a3cce57821deb61217b424c27e899a36b67553 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# Copyright (C) 2024-2026 Maria Lisina
# Copyright (C) 2024-2026 Danil Lisin
# SPDX-License-Identifier: Apache-2.0

if [[ -n "${1}" ]]
then
    data_name="${1}"
    check_table=(${help_table[@]})
    shift
fi

while [[ ${#check_table} -ge 3 ]]
do
    if [[ "${data_name}" == "${check_table[1]}" ]]
    then
        break
    elif [[ "${check_table[1]}" == "${check_table[-3]}" ]]
    then
        notification_text="No requested topic found"
        return
    fi

    shift 3 check_table
done

link_preview_options="$(
    jq --null-input --compact-output \
        '{"is_disabled": true}'
)"

if [[ -n "${data_name}" ]]
then
    output_text="${check_table[3]}"

    keyboard_text1="Back"
    keyboard_data1="help"

    reply_markup="$(
        jq --null-input --compact-output \
            --arg text1 "${keyboard_text1}" \
            --arg data1 "${keyboard_data1}" \
            '{"inline_keyboard": [[{"text": $text1, "callback_data": $data1}]]}'
    )"
else
    output_text="${help_general}"
    . "${units}/help.zsh"
fi