-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
72 lines (50 loc) · 2.05 KB
/
index.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
<?php
use BotMan\BotMan\BotMan;
use BotMan\BotMan\BotManFactory;
use BotMan\BotMan\Drivers\DriverManager;
use Botman\Botman\Drivers\TelegramDriver;
use BotMan\BotMan\Cache\SymfonyCache;
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
use BotMan\BotMan\Messages\Attachments\Image;
use BotMan\BotMan\Messages\Outgoing\OutgoingMessage;
require_once __DIR__."/vendor/autoload.php";
$config = [
//Your driver-specific configuration
"telegram" => [
"token" => "6033423596:AAHKQs-I9Vgfgd2v-XrHCvBMThvUgCq8P0I"
]
];
// Load the driver(s) you want to use
DriverManager::loadDriver(\BotMan\Drivers\Telegram\TelegramDriver::class);
$adapter = new FilesystemAdapter('', 0, __DIR__.'/cache');
$botman = BotManFactory::create($config, new SymfonyCache($adapter));
$botman->hears('/start', function (BotMan $bot) {
$bot->typesAndWaits(0);
$bot->reply('Selamat datang di bot Tricks Original By Kevin Maulana. Akun kamu bernama '.$bot->getUser()->getFirstName().' '.$bot->getUser()->getLastName());
});
// Create an instance
//$botman = BotManFactory::create($config);
// Give the bot something to listen for.
$botman->hears('Assalamualaikum', function (BotMan $bot) {
$bot->typesAndWaits(2);
$bot->reply('Waalaikumsalam '. $bot->getUser()->getFirstName());
});
// Give the bot something to listen for.
$botman->hears('gambar kucing', function (BotMan $bot) {
$att = new Image("https://loremflickr.com/320/240?random=1");
$message = OutgoingMessage::create("Ini kucing lucunya!")->withAttachment($att);
$bot->reply($message);
});
// Give the bot something to listen for.
$botman->hears('gambar', function (BotMan $bot) {
$att = new Image("https://picsum.photos/id/237/200/300");
$message = OutgoingMessage::create("Ini gambarnya bro!")->withAttachment($att);
$bot->reply($message);
});
$botman->fallback(function(BotMan $bot) {
$bot->typesAndWaits(2);
$bot->reply('Maaf, saya tidak memahami pesan anda');
});
// Start listening
$botman->listen();
?>