-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.php
More file actions
86 lines (75 loc) · 2.02 KB
/
index.php
File metadata and controls
86 lines (75 loc) · 2.02 KB
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
<?php
require __DIR__ . '/vendor/autoload.php';
require_once __DIR__ . "/lib/main.php";
$update = file_get_contents("php://input");
$update = json_decode($update, true);
$botName = $_ENV['BOT_NAME'];
$message = $update['message'];
$commands = ['/start', '/help', '/send', '/show', '/joke', '/quote', '/meme', '/quiz', '/tictactoe'];
if ($message) {
$messageId = $message['message_id'];
/**
* "from": {
* "id": **********,
* "is_bot": false,
* "first_name": "Deepanshu",
* "username": "devblin",
* "language_code": "en"
* },
*/
$from = $message['from'];
/**
* "chat": {
* "id": **********,
* "first_name": "Deepanshu",
* "username": "devblin",
* "type": "private"
* },
*/
$chat = $message['chat'];
$text = $message['text'];
/**
* "entities": [
* {
* "offset": 0,
* "length": 5,
* "type": "bot_command"
* }
* ]
*/
$entities = $message['entities'];
$bot = new Bot($message, $from, $chat, $text, $entities);
if ($entities[0]['type'] === "bot_command") {
switch ($text) {
case "/start":
case "/start@$botName":
$bot->start();
break;
case "/help":
case "/help@$botName":
$bot->help();
break;
case "/quiz":
case "/quiz@$botName":
$bot->quiz();
break;
case "/show":
case "/send":
case "/joke":
case "/quote":
case "/meme":
case "/tictactoe":
case "/show@$botName":
case "/send@$botName":
case "/joke@$botName":
case "/quote@$botName":
case "/meme@$botName":
case "/tictactoe@$botName":
$bot->comingSoon();
default:
break;
}
} else if ($entities[0]['type'] === 'mention' && explode("@", $text)[1] === $botName) {
$bot->botMention();
}
}