-
Notifications
You must be signed in to change notification settings - Fork 11
/
start_help.php
98 lines (93 loc) · 3.8 KB
/
start_help.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
<?php
/**
* Copyright (C) 2016-2017 Hunter Ashton
* This file is part of BruhhBot.
* BruhhBot is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* BruhhBot is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with BruhhBot. If not, see <http://www.gnu.org/licenses/>.
*/
function start_message($update, $MadelineProto)
{
if (is_peeruser($update, $MadelineProto)) {
$peer = cache_get_info(
$update,
$MadelineProto,
$update['update']['message']['from_id']
)['bot_api_id'];
$msg_id = $update['update']['message']['id'];
try {
if ($update['update']['message']['message'] != '/start') {
$query = preg_replace("/\/start/", '', $update['update']['message']['message']);
if (preg_match_all('/settings-/', $query, $out)) {
$chat = preg_replace('/ settings-/', '', $query);
settings_menu_deeplink($update, $MadelineProto, $chat);
}
if (preg_match_all('/rules-/', $query, $out)) {
$chat = preg_replace('/ rules-/', '', $query);
get_chat_rules_deeplink($update, $MadelineProto, $chat);
}
return;
}
} catch (Exception $e) {
}
$default = [
'peer' => $peer,
'reply_to_msg_id' => $msg_id,
'parse_mode' => 'html',
];
$botname = getenv('BOT_USERNAME');
$default['message'] = "Hi! I'm a bot made for managing supergroups. To use my functionality, you'll need to add me to your group, and give me all admin priveleges. To explore my commands, use /help. To get started using me in a group, use /add!";
if (isset($default['message'])) {
try {
$sentMessage = $MadelineProto->messages->sendMessage(
$default
);
} catch (Exception $e) {
}
}
}
}
function help_message($update, $MadelineProto)
{
if (is_peeruser($update, $MadelineProto)) {
$peer = cache_get_info(
$update,
$MadelineProto,
$update['update']['message']['from_id']
)['bot_api_id'];
$msg_id = $update['update']['message']['id'];
$default = [
'peer' => $peer,
'reply_to_msg_id' => $msg_id,
'parse_mode' => 'html',
'message' => 'You can navigate the help menu to see each command and how it\'s used. All commands can be started with !, /, or #',
];
$file = file_get_contents('start_help.json');
$startj = json_decode($file, true);
$button_list = [];
foreach ($startj['menus'] as $menu => $desc) {
$button_list[] =
['_' => 'keyboardButtonCallback', 'text' => $menu, 'data' => json_encode([
'q' => 'help2',
'v' => "$menu",
'u' => $peer, ])];
}
$menu = build_keyboard_callback($button_list, 2);
$replyInlineMarkup = ['_' => 'replyInlineMarkup', 'rows' => $menu];
$default['reply_markup'] = $replyInlineMarkup;
}
try {
$sentMessage = $MadelineProto->messages->sendMessage(
$default
);
\danog\MadelineProto\Logger::log($sentMessage);
} catch (Exception $e) {
}
}