-
Notifications
You must be signed in to change notification settings - Fork 2
/
post
executable file
·70 lines (59 loc) · 1.9 KB
/
post
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
# !/bin/bash
#
# Copyright (C) 2020-2022 azrim.
# Copyright (C) 2021 nao04.
# All rights reserved.
# To export first
CDIR=$PWD
DEVICE=$1
# Vars
BANNER="$DEVICE/$DEVICE.png"
JSONFILE=$DEVICE/$DEVICE.json
CHATID="chatidplaceholder"
TG_DIR=$CDIR/telegram
TG_TOKEN="tgtokenplaceholder"
DATE=$(date +'%d %B %Y')
[[ ! -d "$TG_DIR" ]] && git clone https://github.com/fabianonline/telegram.sh/ "$TG_DIR"
TELEGRAM="$TG_DIR"/telegram
tg_msg() {
"$TELEGRAM" -t "$TG_TOKEN" -c "$CHATID" -i "$BANNER" -M \
"$(
for POST in "${@}"; do
echo "${POST}"
done
)"
}
tg_sticker() {
curl -s -F chat_id="$CHATID" -F sticker="$1" https://api.telegram.org/bot"$TG_TOKEN"/sendSticker > /dev/null
}
post() {
# Parsing Json
MAINTAINER=$(jq -r '.MAINTAINER' $JSONFILE | sed "s|_|\x5c_|g")
PLING=$(jq -r '.PLING' $JSONFILE)
DEVICENAME=$(jq -r '.DEVICENAME' $JSONFILE)
DEVICEGROUP=$(jq -r '.DEVICEGROUP' $JSONFILE)
CHANGELOG=$(jq -r '.CHANGELOG' $JSONFILE)
CODENAME=$(jq -r '.CODENAME' $JSONFILE)
[[ ! -z "$DEVICEGROUP" ]] && DEVICEGROUP="[Support group]($DEVICEGROUP)" || DEVICEGROUP="[Support group](https://t.me/silont_support)"
LINK="[Download]($PLING)"
CHANGELOG="[Changelogs & Notes](https://github.com/silont-project/official-devices/raw/master/$DEVICE/$CHANGELOG)"
GROUP="[Group](https://t.me/silont_support)"
CHANNEL="[Channel](https://t.me/silont_updates)"
DEVICE=$(echo "$DEVICE" | sed 's/_/\\_/g')
tg_sticker "CAACAgUAAxkBAAE-BLRf6Zi5wdrMZaYVBS0RWaj0CqJd2gACYQIAAndoICyTqqxZHIg5px4E"
tg_msg \
"📲 *SiLonT Kernel* | $DEVICE ($DEVICENAME)" \
"🔨 by @$MAINTAINER" \
"" \
"🗓 Released: *$DATE*" \
"ℹ️ Codename: *$CODENAME*" \
"" \
"🔹 $LINK" \
"🔹 $CHANGELOG" \
"🔹 $DEVICEGROUP" \
"" \
"*Join* $GROUP | $CHANNEL" \
"#$DEVICE #StayNgelonT"
}
[[ -z $1 ]] && echo "ERROR: No argument given" && echo "" && echo "Usage: post devicecodename" && echo "ex: post surya" && exit
post