blob: 3baaebdb4353e63fc9b2b64856fe811343d6afcd (
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# Copyright (C) 2024-2026 Maria Lisina
# Copyright (C) 2024-2026 Danil Lisin
# SPDX-License-Identifier: Apache-2.0
ib_lock=0
source "${units}/ib_common.zsh"
if [[ -n "${notification_text}" ]]
then
return
fi
ib_hash="$(sha1sum <<< "${user_id}${ib_board}${ib_query}" | cut -F 1)"
ib_file="${cache}/${ib_hash}.json"
until mkdir "${cache}/${ib_hash}.lock"
do
sleep 1
done
source "${units}/ib_file.zsh"
if [[ -n "${notification_text}" ]]
then
rmdir "${cache}/${ib_hash}.lock"
return
fi
source "${units}/ib_post.zsh"
link_preview_options="$(
jq --null-input --compact-output \
--arg url "${ib_sample_url}" \
'{"url": $url, "prefer_small_media": true, "show_above_text": true}'
)"
keyboard_text1="Post link"
keyboard_url1="${ib_url}$(urlencode <<< "${ib_id}")"
reply_markup="$(
jq --null-input --compact-output \
--arg text1 "${keyboard_text1}" \
--arg url1 "${keyboard_url1}" \
'{"inline_keyboard": [[{"text": $text1, "url": $url1}]]}'
)"
if [[ ${#ib_tags} -gt 0 ]]
then
keyboard_text1="Tags (${#ib_tags})"
keyboard_data1="tags ${ib_board} ${ib_post_id}"
reply_markup="$(
jq --compact-output \
--arg text1 "${keyboard_text1}" \
--arg data1 "${keyboard_data1}" \
'.inline_keyboard[0] += [{"text": $text1, "callback_data": $data1}]' \
<<< "${reply_markup}"
)"
fi
rmdir "${cache}/${ib_hash}.lock"
|