aboutsummaryrefslogtreecommitdiff
path: root/units/ib_common.zsh
blob: 9e4307c740b69542e88de441fc1077bdefba097f (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
    ib_board="${1}"
    ib_mode="p"

    source "${units}/ib_config.zsh"

    if [[ -z "${ib_data_url}" ]]
    then
        output_title="Invalid arguments"
        output_text="Unsupported Image Board"
        notification_text="${output_text}"

        return
    fi

    shift
else
    output_title="Invalid arguments"
    output_text="You must specify Image Board and post ID or MD5 hash"
    notification_text="${output_text}"

    return
fi

if [[ -n "${1}" ]]
then
    ib_post_id="${1}"
    shift
else
    output_title="Invalid arguments"
    output_text="You must specify post ID or MD5 hash"
    notification_text="${output_text}"

    return
fi

if [[ ${#ib_post_id} -eq 32 ]]
then
    ib_query="md5:${ib_post_id}"
else
    ib_query="id:${ib_post_id}"
fi