blob: 1ee4d0d1b006db836f227c1ae46f35a014662f0f (
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
# Copyright (C) 2024-2026 Maria Lisina
# Copyright (C) 2024-2026 Danil Lisin
# SPDX-License-Identifier: Apache-2.0
url_table=(
a 3 "safebooru.donmai.us/posts/"
d 3 "danbooru.donmai.us/posts/"
i 4 "www.idolcomplex.com/.*/posts/"
i 4 "idolcomplex.com/.*/posts/"
i 3 "www.idolcomplex.com/posts/"
i 3 "idolcomplex.com/posts/"
k 4 "konachan.com/post/show/"
s 4 "www.sankakucomplex.com/.*/posts/"
i 4 "sankakucomplex.com/.*/posts/"
s 3 "www.sankakucomplex.com/posts/"
i 3 "sankakucomplex.com/posts/"
y 4 "yande.re/post/show/"
)
ib_mode="p"
while [[ ${#url_table} -ge 3 ]]
do
if url_line="$(grep -o "https://\?${url_table[3]}.*" <<< "${command} ${@}")"
then
url_line="$(sed -e 's/https:\/\///' -e 's/ .*//' <<< "${url_line}")"
ib_board="${url_table[1]}"
ib_post_id="$(cut -d '/' -f ${url_table[2]} <<< "${url_line}" | cut -d '?' -f 1)"
break
fi
shift 3 url_table
done
if [[ -z "${ib_post_id}" ]]
then
exit
fi
source "${units}/ib_config.zsh"
if [[ ${#ib_post_id} -gt 32 ]]
then
exit
elif [[ ${#ib_post_id} -eq 32 ]]
then
ib_query="md5:${ib_post_id}"
else
ib_query="id:${ib_post_id}"
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 "${output_text}" ]]
then
keyboard_text1="Delete"
keyboard_data1="delete"
reply_markup="$(
jq --null-input --compact-output \
--arg text1 "${keyboard_text1}" \
--arg data1 "${keyboard_data1}" \
'{"inline_keyboard": [[{"text": $text1, "callback_data": $data1}]]}'
)"
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}")"
keyboard_text2="Delete"
keyboard_data2="delete"
reply_markup="$(
jq --null-input --compact-output \
--arg text1 "${keyboard_text1}" \
--arg url1 "${keyboard_url1}" \
--arg text2 "${keyboard_text2}" \
--arg data2 "${keyboard_data2}" \
'{"inline_keyboard": [[{"text": $text1, "url": $url1}], [{"text": $text2, "callback_data": $data2}]]}'
)"
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"
|