-
Notifications
You must be signed in to change notification settings - Fork 711
处理器Handler
HanSon edited this page Mar 17, 2017
·
2 revisions
vbot 提供五个handler setMessageHandler
, setOnceHandler
, setCustomHandler
,setExitHandler
,setExceptionHandler
去处理消息
-
setMessageHandler
是最常用的处理器,触发机制为接收到消息事件时触发
$robot->server->setMessageHandler(function ($message){
}
-
setOnceHandler
只执行一次,并且在轮询消息时执行,常用语对群组自定义ID等
$robot->server->setOnceHandler(function (){
}
-
setCustomHandler
是较为少用且特殊的处理器,使用场景例如定时触发等
PS:setCustomHandler
的回调函数不会有$message
传入
$robot->server->setCustomHandler(function (){
}
-
setExitHandler
在微信退出登录,或者退出网页登录时触发
$robot->server->setExitHandler(function (){
// some alert
}
-
setExceptionHandler
在微信异常退出时触发
$robot->server->setExceptionHandler(function (){
// some alert
}