Skip to content

Commit

Permalink
Merge pull request #2073 from HDInnovations/Code-Style
Browse files Browse the repository at this point in the history
(Chore) Code Style
  • Loading branch information
HDVinnie authored Jan 10, 2022
2 parents e43e419 + fb1ade3 commit d752eb3
Show file tree
Hide file tree
Showing 1,074 changed files with 6,370 additions and 12,198 deletions.
4 changes: 2 additions & 2 deletions app/Achievements/UserMadeTenComments.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ class UserMadeTenComments extends Achievement
/*
* Triggers whenever an Achiever makes progress on this achievement
*/
public function whenProgress($progress)
public function whenProgress($progress): void
{
}

/*
* Triggers whenever an Achiever unlocks this achievement
*/
public function whenUnlocked($progress)
public function whenUnlocked($progress): void
{
}
}
43 changes: 13 additions & 30 deletions app/Bots/CasinoBot.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@ class CasinoBot

private $chat;

private $target;
private ?\App\Models\User $target = null;

private $type;

private $message;
private ?string $message = null;

private $targeted;
private ?int $targeted = null;

private $log;
private ?string $log = null;

private $expiresAt;
private \Carbon\Carbon $expiresAt;

private $current;
private \Carbon\Carbon $current;

/**
* NerdBot Constructor.
Expand All @@ -57,17 +57,13 @@ public function __construct(private ChatRepository $chatRepository)

/**
* Replace Vars.
*
* @param $output
*
* @return mixed
*/
public function replaceVars($output)
public function replaceVars($output): array|string
{
$output = \str_replace(['{me}', '{command}'], [$this->bot->name, $this->bot->command], $output);
if (\str_contains($output, '{bots}')) {
$botHelp = '';
$bots = Bot::where('active', '=', 1)->where('id', '!=', $this->bot->id)->orderBy('position', 'asc')->get();
$bots = Bot::where('active', '=', 1)->where('id', '!=', $this->bot->id)->orderBy('position')->get();
foreach ($bots as $bot) {
$botHelp .= '( ! | / | @)'.$bot->command.' help triggers help file for '.$bot->name."\n";
}
Expand All @@ -81,14 +77,10 @@ public function replaceVars($output)
/**
* Send Bot Donation.
*
* @param int $amount
* @param string $note
*
* @throws \Exception
*
* @return string
*/
public function putDonate($amount = 0, $note = '')
public function putDonate(int $amount = 0, string $note = ''): string
{
$output = \implode($note, ' ');
$v = \validator(['bot_id' => $this->bot->id, 'amount'=> $amount, 'note'=> $output], [
Expand Down Expand Up @@ -125,13 +117,10 @@ public function putDonate($amount = 0, $note = '')
/**
* Get Bot Donations.
*
* @param string $duration
*
* @throws \Exception
*
* @return string
*/
public function getDonations($duration = 'default')
public function getDonations(string $duration = 'default'): string
{
$donations = \cache()->get('casinobot-donations');
if (! $donations) {
Expand All @@ -152,23 +141,17 @@ public function getDonations($duration = 'default')
/**
* Get Help.
*/
public function getHelp()
public function getHelp(): array|string
{
return $this->replaceVars($this->bot->help);
}

/**
* Process Message.
*
* @param $type
* @param string $message
* @param int $targeted
*
* @throws \Exception
*
* @return bool
*/
public function process($type, User $user, $message = '', $targeted = 0)
public function process($type, User $user, string $message = '', int $targeted = 0): \Illuminate\Contracts\Routing\ResponseFactory|\Illuminate\Http\Response|bool
{
$this->target = $user;
if ($type == 'message') {
Expand Down Expand Up @@ -221,7 +204,7 @@ public function process($type, User $user, $message = '', $targeted = 0)
/**
* Output Message.
*/
public function pm()
public function pm(): \Illuminate\Contracts\Routing\ResponseFactory|\Illuminate\Http\Response|bool
{
$type = $this->type;
$target = $this->target;
Expand Down
12 changes: 6 additions & 6 deletions app/Bots/IRCAnnounceBot.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class IRCAnnounceBot

private $username;

private $registered = false;
private bool $registered = false;

public function __construct()
{
Expand All @@ -72,7 +72,7 @@ public function __destruct()
}
}

private function connect()
private function connect(): void
{
while ($data = \fgets($this->socket)) {
\flush();
Expand All @@ -89,22 +89,22 @@ private function connect()
}
}

private function send_data($data)
private function send_data($data): void
{
\fwrite($this->socket, \sprintf('%s', $data));
}

private function say($channel, $string)
private function say($channel, $string): void
{
$this->send_data(\sprintf('PRIVMSG %s %s', $channel, $string));
}

private function join($channel)
private function join($channel): void
{
$this->send_data(\sprintf('JOIN %s', $channel));
}

public function message($channel, $message)
public function message($channel, $message): void
{
// Messages an specific IRC Channel
if ($this->joinchannel && \preg_match('/#(\w*[a-zA-Z_0-9]+\w*)/', $channel)) {
Expand Down
Loading

0 comments on commit d752eb3

Please sign in to comment.