authorization

This commit is contained in:
mercury
2023-02-10 19:20:09 +04:00
parent a06252d8f0
commit 8d47b5cd52
3 changed files with 26 additions and 11 deletions
+15
View File
@@ -39,11 +39,25 @@ class Bot
'new_member_id' => $input['my_chat_member']['new_chat_member']['user']['id'] ?? false,
'new_member_status' => $input['my_chat_member']['new_chat_member']['status'] ?? false,
];
$this->auth();
$this->session();
$this->action();
$this->callbackCheck();
}
public function auth()
{
$file = __DIR__ . '/config.php';
require $file;
if (empty($c['admin'])) {
$c['admin'] = $this->input['from'];
file_put_contents($file, "<?php\n\n\$c = " . var_export($c, true) . ";\n");
} elseif ($c['admin'] != $this->input['from']) {
$this->send($this->input['chat'], 'you are not authorized', $this->input['message_id']);
exit;
}
}
public function callbackCheck()
{
if (empty($this->callback) && !empty($this->input['callback_id'])) {
@@ -84,6 +98,7 @@ class Bot
switch (true) {
// смена айпи сервера
case preg_match('~^/menu$~', $this->input['message'], $m):
case preg_match('~^/start$~', $this->input['message'], $m):
case preg_match('~^/menu$~', $this->input['callback'], $m):
case preg_match('~^/menu (?P<type>addpeer) (?P<arg>(?:-)?\d+)$~', $this->input['callback'], $m):
case preg_match('~^/menu (?P<type>wg) (?P<arg>(?:-)?\d+)$~', $this->input['callback'], $m):