/**
  * @param Rpc $rpc
  * @return PromiseInterface
  */
 public function rpc(Rpc $rpc)
 {
     $this->busy = true;
     return $this->messenger->rpc($rpc)->always(function () {
         $this->busy = false;
         $this->emit('done', [$this]);
     });
 }
 /**
  * Modifies a term's karma.
  *
  * @param string $term   Term to modify
  * @param string $action Karma action (either ++ or --)
  * @param \Phergie\Irc\Event\UserEvent $event
  * @param \Phergie\Irc\Bot\React\EventQueueInterface $queue
  * @return bool|\React\Promise\Promise
  */
 protected function modifyKarma($term, $action, UserEvent $event, Queue $queue)
 {
     $nick = $event->getNick();
     $canonicalTerm = $this->getCanonicalTerm($term, $nick);
     if ($canonicalTerm == strtolower($nick)) {
         $message = 'You can\'t give yourself karma.';
         $queue->ircPrivmsg($event->getSource(), $message);
         return false;
     }
     $karma = 0;
     return $this->messenger->rpc(MessageFactory::rpc('fetchKarma', ['term' => $canonicalTerm]))->then(function ($payload) use($event, $queue, $action, $term, $canonicalTerm, &$karma) {
         $this->logDebug('payload: ' . var_export($payload, true));
         $karma = $payload['karma'] + ($action == '++' ? 1 : -1);
         return MessageFactory::rpc('modifyKarma', ['term' => $canonicalTerm, 'karma' => $karma]);
     })->then([$this->messenger, 'rpc'])->then(function ($payload) use($event, $queue, $action, $term) {
         $this->logDebug('payload: ' . var_export($payload, true));
         $queue->ircPrivmsg($event->getSource(), $this->getUserMessage('karma' . $action, $term));
         return $payload['karma'];
     });
 }