This repository has been archived by the owner on Mar 26, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
hook.example.php
62 lines (50 loc) · 1.76 KB
/
hook.example.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
<?php
/**
* Created by PhpStorm.
* User: Azhe
* Date: 04/08/2018
* Time: 22.47
*/
require_once __DIR__ . '/vendor/autoload.php';
// Load all in /Resources dir
foreach (glob('Resources/*/*.php') as $files) {
include_once $files;
}
// load all under folder src
foreach (glob('src/*/*.php') as $files) {
include_once $files;
}
$commands_paths = [
__DIR__ . '/Commands/SystemCommands',
__DIR__ . '/Commands/UserCommands/Additional',
__DIR__ . '/Commands/UserCommands/Bot',
__DIR__ . '/Commands/UserCommands/CekResi',
__DIR__ . '/Commands/UserCommands/FedBan',
__DIR__ . '/Commands/UserCommands/Group',
__DIR__ . '/Commands/UserCommands/Labs',
__DIR__ . '/Commands/UserCommands/Member',
__DIR__ . '/Commands/UserCommands/Security',
__DIR__ . '/Commands/UserCommands/Sudoer',
__DIR__ . '/Commands/UserCommands/Tagging',
__DIR__ . '/Commands/UserCommands/Texting',
];
try {
// Create Telegram API object
$telegram = new Longman\TelegramBot\Telegram(bot_token, bot_username);
// Set custom Upload and Download paths
$telegram->setDownloadPath(__DIR__ . '/Download');
$telegram->setUploadPath(__DIR__ . '/Upload');
// Handle telegram webhook request
$telegram->addCommandsPaths($commands_paths);
// Logging (Error, Debug and Raw Updates)
// Longman\TelegramBot\TelegramLog::initDebugLog(__DIR__ . '/{bot_username}_debug.log');
// Longman\TelegramBot\TelegramLog::initErrorLog(__DIR__ . '/{bot_username}_error.log');
// Longman\TelegramBot\TelegramLog::initUpdateLog(__DIR__ . '/{bot_username}_update.log');
// Handle Webhook Request
$telegram->handle();
// Enable Limiter
$telegram->enableLimiter();
} catch (Longman\TelegramBot\Exception\TelegramException $e) {
// Silence is golden!
}
echo 'Hook Worked!';