forked from Hanson/vbot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcustom.php
More file actions
36 lines (29 loc) · 829 Bytes
/
Copy pathcustom.php
File metadata and controls
36 lines (29 loc) · 829 Bytes
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
<?php
/**
* Created by PhpStorm.
* User: HanSon
* Date: 2016/12/7
* Time: 16:33.
*/
require_once __DIR__.'./../vendor/autoload.php';
use Hanson\Vbot\Foundation\Vbot;
use Hanson\Vbot\Message\Entity\Text;
$robot = new Vbot([
'user_path' => __DIR__.'/./../tmp/',
'session' => 'console',
]);
$flag = false;
$robot->server->setCustomerHandler(function () use (&$flag) {
// RemarkName,代表的改用户在你通讯录的名字
$contact = contact()->getUsernameByRemarkName('hanson');
if ($contact === false) {
echo '找不到你要的联系人,请确认联系人姓名';
return;
}
if (!$flag) {
Text::send($contact, '来轰炸吧');
$flag = true;
}
Text::send($contact, '测试'.\Carbon\Carbon::now()->toDateTimeString());
});
$robot->server->run();