-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.php
122 lines (87 loc) · 2.35 KB
/
app.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
<?php
define("TOKEN_KEY", "");
class telegramBot
{
private function getBot($method = "getMe", $params = [])
{
$url = "https://api.telegram.org/bot" . TOKEN_KEY . "/" . $method;
$init = curl_init();
curl_setopt_array(
$init,
[
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
// CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $params,
CURLOPT_HTTPHEADER=> ['Content-Type:multipart/form-data'] ,
]
);
$res = curl_exec($init);
curl_close($init);
if (!curl_error($init)) {
return json_decode($res, true);
}
}
public function SetWebhook($url , $max_connections=100)
{
return $this->getBot('setWebhook',
[
'url'=>$url,
'max_connections'=>$max_connections,
]
);
}
public function DeleteWebhook()
{
return $this->getBot("deleteWebhook");
}
public function GetWebhookInfo()
{
return $this->getBot("getWebhookInfo") ;
}
public function SendMessage($chat_id,$text,$reply_markup=null,$parse_mode="HTML",$dwp_preview=true)
{
return $this->getBot(
"sendMessage" ,
[
'chat_id'=> $chat_id ,
'text'=>$text ,
'parse_mode'=> $parse_mode ,
'disable_web_page_preview'=>$dwp_preview ,
"reply_markup"=>$reply_markup
]
);
}
public function senToAdmineBot($admin_chat_id , $mesg ,$chat_id_user ,$name_user)
{
return $this->SendMessage($admin_chat_id,
"$mesg
chat_id : $chat_id_user
user : $name_user
"
);
}
function SendDocument($chat_id,$document,$thumb,$reply_markup=null,$parse_mode="HTML"){
return $this->getBot(
'sendDocument',[
'chat_id'=>$chat_id,
'document'=> $document,
'thumb'=>$thumb,
'parse_mode'=>$parse_mode,
'reply_markup'=>$reply_markup
]
);
}
}
$get_api = file_get_contents('php://input');
$update = json_decode($get_api);
if ($update) file_put_contents("log.json", $get_api);
$message = $update->message;
$message_id=$message->message_id ;
$text = $message->text;
$first_name = $message->chat->first_name;
$chate_id = $message->chat->id;
$file_id= $message ->document->file_id ;
$file_name= $message ->document->file_name ;
$file_caption= $message ->document->caption ;
$thump_id= $message ->document->thumb->file_id;