private function setActionKilled() { $this->bot->onPrivateMessage("/killed/", function ($response) { //do validation to make sure it came from authorized user $this->bot->askStop(); }); }
public function main() { $this->bot = new Philip($this->config); $factory = new \ChatterBotFactory(); $clever = $factory->create(\ChatterBotType::PANDORABOTS, 'b0dafd24ee35a477'); $session = $clever->createSession(); $this->bot->onMessages('/ai(.*)/u', function (Event $event) use(&$clever, &$session) { $matches = $event->getMatches(); $message = $matches[0]; $response = ""; try { $response = $session->think($message); } catch (\Exception $e) { $response = "I can't reach the Cloud. I don't know how to answer"; $session = $clever->createSession(); } $event->addResponse(Response::msg($event->getRequest()->getSource(), $response)); }); $this->bot->run(); }
public function testLoadPlugins() { $this->if($object = new TestedClass())->and($plugin = new \mock\Philip\AbstractPlugin($object))->and($this->calling($plugin)->getName = $name = uniqid())->and($otherPlugin = new \mock\Philip\AbstractPlugin($object))->and($this->calling($otherPlugin)->getName = $otherName = uniqid())->then->object($object->loadPlugins(array($plugin, $otherPlugin)))->isIdenticalTo($object)->mock($plugin)->call('getName')->once()->mock($otherPlugin)->call('getName')->once()->object($object->getPlugin($name))->isIdenticalTo($plugin)->object($object->getPlugin($otherName))->isIdenticalTo($otherPlugin); }