+ $this->last_contact = time();
+ }
+
+ public function sendWhisper($to, $msg) {
+ $this->logger->info('sending whisper to '.$to.': '.$msg);
+ try {
+ $response = $this->token->request()->post('/whispers?from_user_id='.$this->user_id.'&to_user_id='.$to, [
+ 'message' => $msg,
+ ]);
+ if (!$response->successful()) {
+ $this->logger->error('sending whisper to '.$to.': '.$response->status());
+ }
+ } catch (\Exception $e) {
+ $this->logger->error('sending whisper to '.$to.': '.$e->getMessage());
+ }
+ }
+
+
+ protected function listenCommands() {
+ $this->getLoop()->addPeriodicTimer(1, function () {
+ if (!$this->isReady()) return;
+ $command = TwitchBotCommand::where('bot_nick', '=', $this->nick)->where('status', '=', 'pending')->oldest()->first();
+ if ($command) {
+ try {
+ $command->execute($this);
+ } catch (\Exception $e) {
+ }
+ }
+ });