我创建了一个带有按钮和开关的 viber 机器人。当我选择汽车品牌和型号时,一切正常,但机器人会从 @media only screen and (max-width: 600px) {
.fa-barcode {
right: 20px !important;
}
#cameras-selection {
position: absolute;
pointer-events: visible;
margin: 10px;
}
#close-camera-container {
position: absolute;
right: 0;
margin: 10px;
pointer-events: visible;
}
}
#container {
display: none;
pointer-events: none;
width: 320px;
height: 240px;
}
.test {
width: 100%;
}
发送额外的消息。这是它的外观:Screenshot of chat with this bug。
我没有添加带有第一个按钮(带有品牌)的代码,因为它们一切正常
按钮:
->setText('Model')
用答案切换:
->onText('||', function ($event) use ($bot, $botSender, $log) {
$caseNumber = $event->getMessage()->getText();
$log->info('onText demo handler #' . $caseNumber);
$client = $bot->getClient();
$receiverId = $event->getSender()->getId();
switch ($caseNumber) {
case 0:
$client->sendMessage(
(new \Viber\Api\Message\Text())
->setSender($botSender)
->setReceiver($receiverId)
->setText('Model')
->setKeyboard(
(new \Viber\Api\Keyboard())
->setButtons([
(new \Viber\Api\Keyboard\Button())
->setBgColor('#ffffff')
->setTextSize('small')
->setTextHAlign('center')
->setActionType('reply')
->setActionBody('Megane')
->setText('Megane'),
(new \Viber\Api\Keyboard\Button())
->setBgColor('#ffffff')
->setTextSize('small')
->setTextHAlign('center')
->setActionType('reply')
->setActionBody('Zoe')
->setText('Zoe'),
(new \Viber\Api\Keyboard\Button())
->setBgColor('#ffffff')
->setTextSize('small')
->setTextHAlign('center')
->setActionType('reply')
->setActionBody('Scenic')
->setText('Scenic'),
(new \Viber\Api\Keyboard\Button())
->setBgColor('#ffffff')
->setTextSize('small')
->setTextHAlign('center')
->setActionType('reply')
->setActionBody('Renault Grand')
->setText('Grand'),
(new \Viber\Api\Keyboard\Button())
->setBgColor('#ffffff')
->setTextSize('small')
->setTextHAlign('center')
->setActionType('reply')
->setActionBody('Kangoo')
->setText('Kangoo'),
(new \Viber\Api\Keyboard\Button())
->setBgColor('#ffffff')
->setTextSize('small')
->setTextHAlign('center')
->setActionType('reply')
->setActionBody('Talisman')
->setText('Talisman'),
])
)
);
}
如何删除多余的 $caseNumber1 = preg_replace('||', '', $event->getMessage()->getText());
switch ($caseNumber1) {
case 'Megane':
$client->sendMessage(
(new \Viber\Api\Message\Text())
->setSender($botSender)
->setReceiver($receiverId)
->setText('Renault Megane'),
$buttons
);
}
消息?