예제 #1
0
 public function main()
 {
     $Transact = new Transact($this->db);
     if ($this->noParams() == 2) {
         $user_receiving = Query::getUserMatchingStringOrErrorMessage($this->db, $this->Message->Chat, $this->getParam());
         if (is_string($user_receiving)) {
             Telegram::talk($this->Message->Chat->id, $user_receiving);
             return false;
         }
         $Transaction = new Transaction($this->Message->User, $user_receiving, $this->getParam(1), new TransactionType(TransactionType::Manual));
         $Transact->performTransaction($Transaction);
         if ($Feedback = $Transact->Feedback->getFeedback()) {
             $out = emoji("0x1F4E2") . " " . $Feedback . "\n`   `• `" . $user_receiving->getName() . "` now has 💰*" . $user_receiving->getBalance() . "*" . "\n`   `• `You've` got 💰*" . $this->Message->User->getBalance() . "* left.";
             if ($user_receiving->user_id != -1) {
                 $out .= "\n`   `• `The Bank` took 2%, or 💰*" . round($this->getParam(1) * 0.02, 2) . "*";
             }
             Telegram::talk($this->Message->Chat->id, $out);
         } else {
             Telegram::talk($this->Message->Chat->id, "I'm so sorry brah...");
         }
     } else {
         Telegram::talk($this->Message->Chat->id, "Like this fam " . emoji("0x1F449") . "  /send richardstallman 10");
     }
     return true;
 }
예제 #2
0
 public function main()
 {
     if ($this->isParam()) {
         $user = Query::getUserMatchingStringOrErrorMessage($this->db, $this->Message->Chat, $this->getParam());
         if (is_string($user)) {
             Telegram::talk($this->Message->Chat->id, $user);
             return false;
         }
         Telegram::talk($this->Message->Chat->id, $user->getNameLevelAndTitle() . " has " . emoji("0x1F4B0") . "*" . $user->getBalance() . "*, brah");
     } else {
         Telegram::talk($this->Message->Chat->id, "You've got " . emoji("0x1F4B0") . "*" . $this->Message->User->getBalance() . "*, brah");
     }
     return true;
 }
예제 #3
0
 public function main()
 {
     $Level = new \GroupBot\Brains\Level\Level();
     if ($this->isParam()) {
         $user = Query::getUserMatchingStringOrErrorMessage($this->db, $this->Message->Chat, $this->getParam());
         if (is_string($user)) {
             $out = $user;
         } else {
             $out = emoji(0x1f4ef) . " Make way for " . $user->getNameLevelAndTitle() . "!";
         }
     } else {
         $user = $this->Message->User;
         $out = emoji(0x1f4ef) . " Greetings " . $user->getNameLevelAndTitle() . "." . "\nYou may rise to level " . ($user->level + 1) . " for a price of " . $Level->getLevelPrice($user->level + 1) . " Coin." . "\nPlease use /buylevel to do this.";
     }
     Telegram::talk($this->Message->Chat->id, $out);
 }
예제 #4
0
 private function performVote()
 {
     if (isset($this->chat)) {
         $user = Query::getUserMatchingStringOrErrorMessage($this->db, $this->chat, $this->getParam(0));
     } else {
         $user = Query::getUserMatchingStringOrErrorMessage($this->db, $this->Message->Chat, $this->getParam(0));
     }
     if (is_string($user)) {
         return $user;
     }
     if (strcasecmp($this->getParam(0), BOT_FRIENDLY_NAME) === 0) {
         return "wow, thx brah! " . emoji(0x1f618);
     }
     if (!$user) {
         return emoji(0x1f44e) . " Can't find that user, brah";
     }
     if ($user->user_id == $this->Message->User->user_id) {
         return emoji(0x1f44e) . " You can't vote for yourself!";
     }
     switch ($this->getParam(1)) {
         case 'up':
             $voteType = new VoteType(VoteType::Up);
             break;
         case 'down':
             $voteType = new VoteType(VoteType::Down);
             break;
         case 'neutral':
             $voteType = new VoteType(VoteType::Neutral);
             break;
         default:
             return emoji(0x1f44e) . " Your vote must be either *up*, *down* or *neutral*.";
     }
     $DbUser = new \GroupBot\Database\User($this->db);
     $voted_for = $DbUser->getUserFromId($user->user_id);
     $userVote = new UserVote();
     $userVote->construct($this->Message->User, $voted_for, $voteType);
     $Vote = new \GroupBot\Brains\Vote\Vote($this->db);
     if ($Vote->SQL->check_if_vote_exists($userVote)) {
         $this->vote_cast = true;
         return emoji(0x1f528) . " Vote unchanged - you've voted this way before!";
     }
     $Vote->SQL->update_vote($userVote);
     $this->vote_cast = true;
     $rank = $Vote->getVoteTotalForUserInChat($userVote->voted_for, $this->Message->Chat->id);
     $vote_prefix = $rank > 0 ? "+" : "";
     return emoji(0x1f528) . " Vote updated. *" . $userVote->voted_for->getName() . "* is now on *{$vote_prefix}{$rank}*";
 }