-
Notifications
You must be signed in to change notification settings - Fork 18
/
functions.php
158 lines (135 loc) · 3.75 KB
/
functions.php
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<?php
//Answer CallBack Query
function acq($id, $text, $alert = false){
global $api;
global $chatID;
$args = array(
'callback_query_id' => $id,
'text' => $text,
'show_alert' => $alert
);
$r = new HttpRequest("post", "https://api.telegram.org/$api/answerCallbackQuery", $args);
$rr = $r->getResponse();
return $rr;
}
//Send Message
function sm($chatID, $text, $rmf = false, $pm = false, $dis = false, $replyto = false, $preview = false, $inline = false){
global $api;
global $update;
if($inline){
$rm = array('inline_keyboard' => $rmf);
} else {
$rm = array('keyboard' => $rmf,
'resize_keyboard' => true
);
}
$rm = json_encode($rm);
$args = array(
'chat_id' => $chatID,
'text' => $text,
'disable_notification' => $dis
);
if($replyto) $args['reply_to_message_id'] = $update["message"]["message_id"];
if($rmf) $args['reply_markup'] = $rm;
if($preview) $args['disable_web_page_preview'] = $preview;
if($pm) $args['parse_mode'] = $pm;
if($text)
{
$r = new HttpRequest("post", "https://api.telegram.org/$api/sendmessage", $args);
$rr = $r->getResponse();
$ar = json_decode($rr, true);
}
return $ar;
}
//Send Voice
function sv($chatID, $file_id, $caption, $rmf = false, $pm = false, $dis = false, $replyto = false, $inline = false){
global $api;
global $update;
if($inline){
$rm = array('inline_keyboard' => $rmf);
} else {
$rm = array('keyboard' => $rmf,
'resize_keyboard' => true
);
}
$rm = json_encode($rm);
$args = array(
'chat_id' => $chatID,
'voice' => $file_id,
'disable_notification' => $dis
);
if($replyto) $args['reply_to_message_id'] = $update["message"]["message_id"];
if($caption) $args['caption'] = $caption;
if($rmf) $args['reply_markup'] = $rm;
if($pm) $args['parse_mode'] = $pm;
if($file_id)
{
$r = new HttpRequest("post", "https://api.telegram.org/$api/sendVoice", $args);
$rr = $r->getResponse();
$ar = json_decode($rr, true);
}
return $rr;
}
//Edit Message
function em($chatID, $messageID, $text, $rmf = false, $inline = false, $pm = false){
global $api;
if($inline){
$rm = array('inline_keyboard' => $rmf);
} else {
$rm = array(
'keyboard' => $rmf,
'resize_keyboard' => true
);
}
$rm = json_encode($rm);
$args = array(
'chat_id' => $chatID,
'message_id' => $messageID,
'text' => $text
);
if($rmf) $args['reply_markup'] = $rm;
if($pm) $args['parse_mode'] = $pm;
if($text){
$r = new HttpRequest("post", "https://api.telegram.org/$api/editMessageText", $args);
$rr = $r->getResponse();
}
return $rr;
}
//Edit Message keyboard
function emk($chatID, $messageID, $rmf, $inline_msgid = false){
global $api;
$rm = array('inline_keyboard' => $rmf);
$rm = json_encode($rm);
$args["reply_markup"] = $rm;
if ($inline_msgid) {
$args["inline_message_id"] = $inline_msgid;
} else {
$args["chat_id"] = $chatID;
$args["message_id"] = $messageID;
}
new HttpRequest("post", "https://api.telegram.org/$api/editMessageReplyMarkup", $args);
}
//Edit Message caption
function emc($chatID, $messageID, $caption, $rmf, $inline_msgid = false){
global $api;
$rm = array('inline_keyboard' => $rmf);
$rm = json_encode($rm);
$args["reply_markup"] = $rm;
if ($inline_msgid) {
$args["inline_message_id"] = $inline_msgid;
} else {
$args["chat_id"] = $chatID;
$args["message_id"] = $messageID;
}
$args["caption"] = $caption;
new HttpRequest("post", "https://api.telegram.org/$api/editMessageCaption", $args);
}
//Delete Message
function dm($chatID, $msgID){
global $api;
$args = array(
"chat_id" => $chatID,
"message_id" => $msgID
);
new HttpRequest("post", "https://api.telegram.org/$api/deleteMessage", $args);
}