protected function postMessage($message, $name = null) { $name = is_null($name) ? static::INFO_NAME : $name; $user = Shotbow_ChatBot_User::create(static::INFO_ID, $name); // Post to DB for website $stmt = $this->dbh->prepare('INSERT INTO dark_taigachat (user_id,username,`date`,message,activity) VALUES (?,?,?,?,0)'); $stmt->execute([static::INFO_ID, $user->getName(), time(), $message]); $this->postToInternal($message, $user); }
public function testAllCommandsDontError() { $dbh = new PDO(); $bot = new Bot($dbh); $navarr = \Shotbow_ChatBot_User::create(1, 'Navarr'); $commands = $bot->getCommandList(); foreach ($commands as $command => $callable) { $bot->process($navarr, "!{$command}"); } }
/** * @return Shotbow_ChatBot_User[] */ protected function getUsersInChat() { $sql = <<<MySQL SELECT user.user_id, user.username FROM dark_taigachat_activity AS activity LEFT JOIN xf_user AS user ON (user.user_id = activity.user_id) WHERE activity.date > UNIX_TIMESTAMP()-150 AND user.visible=1 ORDER BY activity.date DESC MySQL; $stmt = $this->dbh->query($sql); $results = $stmt->fetchAll(PDO::FETCH_ASSOC); $users = []; foreach ($results as $result) { $users[] = Shotbow_ChatBot_User::create($result['user_id'], $result['username']); } return $users; }
public function testToString() { $user = \Shotbow_ChatBot_User::create(2, 'lazertester'); $stringified = (string) $user; $this->assertEquals('lazertester', $stringified); }
<?php require_once 'vendor/autoload.php'; $user = Shotbow_ChatBot_User::create(1, 'Navarr');