-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.php
77 lines (55 loc) · 2.69 KB
/
bot.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
<?php
use BotMan\BotMan\BotMan;
use BotMan\BotMan\BotManFactory;
use BotMan\BotMan\Drivers\DriverManager;
use BotMan\Drivers\Telegram\TelegramDriver;
require_once $_SERVER['DOCUMENT_ROOT'] . '/BOT-Telegram-IBMWatson-Cat-Dog-Recognition/vendor/autoload.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/BOT-Telegram-IBMWatson-Cat-Dog-Recognition/database/config.php';
date_default_timezone_set('Asia/Jakarta');
$configs = [
"telegram" => [
"token" => file_get_contents("private/TOKEN.txt")
]
];
DriverManager::loadDriver(TelegramDriver::class);
$botman = BotManFactory::create($configs);
// $botman->group(['recipient' => '-1001307666764'], function(Botman $bot) { //'-1001184380882' grup api
// $bot->hears("/start@CatnDogBot", function (BotMan $bot) {
// $user = $bot->getUser();
// $firstname = $user->getFirstName();
// $bot->reply("Willkommen $firstname 😊");
// });
// // $bot->hears("/cek {url}", function (BotMan $bot, $url){
// // require_once $_SERVER['DOCUMENT_ROOT'] . '/BOT-Telegram-IBMWatson-Cat-Dog-Recognition/functions/getter.php';
// // require_once $_SERVER['DOCUMENT_ROOT'] . '/BOT-Telegram-IBMWatson-Cat-Dog-Recognition/functions/IBM_API.php';
// // $classification = classifyImage($url);
// // include "functions/request.php";
// // $message = getMessage($url);
// // $bot->reply($message);
// // });
// $bot->hears("/help@CatnDogBot", function (BotMan $bot) {
// $bot->reply("Bot ini mengklasifikasikan gambar kucing dan anjing" . PHP_EOL . "/start - untuk mendapat sapaan" . PHP_EOL .
// "/cek {url} - untuk mengecek gambar" . PHP_EOL . "/help - untuk mendapatkan bantuan");
// });
// });
$botman->hears("/start", function (BotMan $bot) {
$user = $bot->getUser();
$firstname = $user->getFirstName();
$bot->reply("Willkommen $firstname 😊");
});
$botman->hears("/cek {url}", function (BotMan $bot, $url){
require_once $_SERVER['DOCUMENT_ROOT'] . '/BOT-Telegram-IBMWatson-Cat-Dog-Recognition/functions/getter.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/BOT-Telegram-IBMWatson-Cat-Dog-Recognition/functions/IBM_API.php';
include "functions/request.php";
$message = getMessage($url);
$bot->reply($message);
});
$botman->hears("/help", function (BotMan $bot) {
$bot->reply("Bot ini mengklasifikasikan gambar kucing dan anjing" . PHP_EOL . "/start - untuk mendapat sapaan" . PHP_EOL .
"/cek {url} - untuk mengecek gambar" . PHP_EOL . "/help - untuk mendapatkan bantuan");
});
$botman->fallback(function (BotMan $bot) {
$message = $bot->getMessage()->getText();
$bot->reply("Perintah tidak dikenali '$message'");
});
$botman->listen();