-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcore.sh
129 lines (101 loc) · 2.58 KB
/
core.sh
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
117
118
119
120
121
122
123
124
125
126
127
128
129
#!/bin/bash
# Contain API key: ${TOKEN} and ${USER_ID}
source "${BASH_SOURCE%/*}/config.sh"
# Available methods
###################
get_me () {
echo "Getting bot info"
URL=$API_URL"bot"$TOKEN"/getMe"
$CURL -X POST $URL -F chat_id="$USER_ID"
}
send_message () {
if [ $# -eq 0 ]
then
echo "send_message require an argument"
return
fi
local MSG=$1
echo "Sending to user: $USER_ID message: $MSG"
URL=$API_URL"bot"$TOKEN"/sendMessage"
$CURL -s -X POST $URL -d chat_id=$USER_ID -d text="$MSG"
}
send_audio () {
if [ $# -eq 0 ]
then
echo "send_audio require an argument"
return
fi
local PATH=$1
local CAPTION=$2
if ! [[ "$PATH" =~ ^http* ]]; then
PATH="@$PATH"
fi
echo "Sending to user: $USER_ID audio: $PATH"
URL=$API_URL"bot"$TOKEN"/sendAudio"
$CURL -s -X POST $URL -F chat_id=$USER_ID -F audio=$PATH -F caption="$CAPTION"
}
send_image () {
if [ $# -eq 0 ]
then
echo "send_image require an argument"
return
fi
local PATH=$1
local CAPTION=$2
if ! [[ "$PATH" =~ ^http* ]]; then
PATH="@$PATH"
fi
echo "Sending to user: $USER_ID image: $PATH"
URL=$API_URL"bot"$TOKEN"/sendPhoto"
$CURL -s -X POST $URL -F chat_id=$USER_ID -F photo=$PATH -F caption="$CAPTION"
}
send_video () {
if [ $# -eq 0 ]
then
echo "send_video require an argument"
return
fi
local PATH=$1
local CAPTION=$2
if ! [[ "$PATH" =~ ^http* ]]; then
PATH="@$PATH"
fi
echo "Sending to user: $USER_ID image: $PATH"
URL=$API_URL"bot"$TOKEN"/sendVideo"
$CURL -s -X POST $URL -F chat_id=$USER_ID -F video=$PATH -F caption="$CAPTION"
}
send_document () {
if [ $# -eq 0 ]
then
echo "send_document require an argument"
return
fi
local PATH=$1
local CAPTION=$2
if ! [[ "$PATH" =~ ^http* ]]; then
PATH="@$PATH"
fi
echo "Sending to user: $USER_ID document: $PATH"
URL=$API_URL"bot"$TOKEN"/sendDocument"
$CURL -X POST $URL -F chat_id="$USER_ID" -F caption="$CAPTION" -F document="$PATH"
}
send_gif () {
if [ $# -eq 0 ]
then
echo "send_gif require an argument"
return
fi
local PATH=$1
local CAPTION=$2
if ! [[ "$PATH" =~ ^http* ]]; then
PATH="@$PATH"
fi
echo "Sending gif to user $USER_ID from: $PATH"
URL=$API_URL"bot"$TOKEN"/sendAnimation"
$CURL -s -X POST $URL -F chat_id=$USER_ID -F animation=$PATH -F caption="$CAPTION"
}
# Custom requests
#################
send_public_ip () {
send_message "Your IP is: $($CURL ifconfig.co)"
}