Skip to content

Commit

Permalink
Merge pull request #1158 from HDInnovations/development
Browse files Browse the repository at this point in the history
(Refactor) Encapsed Strings To Sprintf
  • Loading branch information
HDVinnie authored Feb 18, 2020
2 parents 1e03562 + 84aafbb commit 610a5f7
Show file tree
Hide file tree
Showing 61 changed files with 235 additions and 217 deletions.
2 changes: 1 addition & 1 deletion app/Bots/CasinoBot.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function putDonate($amount = 0, $note = '')
$output = implode(' ', $note);
$v = validator(['bot_id' => $this->bot->id, 'amount'=> $amount, 'note'=> $output], [
'bot_id' => 'required|exists:bots,id|max:999',
'amount' => "required|numeric|min:1|max:{$this->target->seedbonus}",
'amount' => sprintf('required|numeric|min:1|max:%s', $this->target->seedbonus),
'note' => 'required|string',
]);
if ($v->passes()) {
Expand Down
13 changes: 7 additions & 6 deletions app/Bots/IRCAnnounceBot.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ public function __construct()
$this->joinchannels = config('irc-bot.joinchannels');
$this->socket = fsockopen($this->server, $this->port);

$this->send_data("NICK {$this->username}");
$this->send_data("USER {$this->username} {$this->hostname} {$this->server} {$this->username}");
$this->send_data(sprintf('NICK %s', $this->username));
$this->send_data(sprintf('USER %s %s %s %s', $this->username, $this->hostname, $this->server, $this->username));

$this->connect();
}
Expand All @@ -56,7 +56,7 @@ private function connect()
if ($ex[0] == 'PING') {
$this->send_data('PONG '.$ex[1]);
if ($this->nickservpass) {
$this->send_data("NICKSERV IDENTIFY {$this->nickservpass}");
$this->send_data(sprintf('NICKSERV IDENTIFY %s', $this->nickservpass));
}

return;
Expand All @@ -66,17 +66,18 @@ private function connect()

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

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

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

public function message($channel, $message)
Expand Down
26 changes: 13 additions & 13 deletions app/Bots/NerdBot.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public function getBanker($duration = 'default')
cache()->put('nerdbot-banker', $banker, $this->expiresAt);
}

return "Currently [url=/users/{$banker->username}]{$banker->username}[/url] Is The Top BON Holder On ".config('other.title').'!';
return sprintf('Currently [url=/users/%s]%s[/url] Is The Top BON Holder On ', $banker->username, $banker->username).config('other.title').'!';
}

/**
Expand All @@ -118,7 +118,7 @@ public function getSnatched($duration = 'default')
cache()->put('nerdbot-snatched', $snatched, $this->expiresAt);
}

return "Currently [url=/torrents/{$snatched->id}]{$snatched->name}[/url] Is The Most Snatched Torrent On ".config('other.title').'!';
return sprintf('Currently [url=/torrents/%s]%s[/url] Is The Most Snatched Torrent On ', $snatched->id, $snatched->name).config('other.title').'!';
}

/**
Expand All @@ -136,7 +136,7 @@ public function getLeeched($duration = 'default')
cache()->put('nerdbot-leeched', $leeched, $this->expiresAt);
}

return "Currently [url=/torrents/{$leeched->id}]{$leeched->name}[/url] Is The Most Leeched Torrent On ".config('other.title').'!';
return sprintf('Currently [url=/torrents/%s]%s[/url] Is The Most Leeched Torrent On ', $leeched->id, $leeched->name).config('other.title').'!';
}

/**
Expand All @@ -154,7 +154,7 @@ public function getSeeded($duration = 'default')
cache()->put('nerdbot-seeded', $seeded, $this->expiresAt);
}

return "Currently [url=/torrents/{$seeded->id}]{$seeded->name}[/url] Is The Most Seeded Torrent On ".config('other.title').'!';
return sprintf('Currently [url=/torrents/%s]%s[/url] Is The Most Seeded Torrent On ', $seeded->id, $seeded->name).config('other.title').'!';
}

/**
Expand All @@ -172,7 +172,7 @@ public function getFreeleech($duration = 'default')
cache()->put('nerdbot-fl', $fl, $this->expiresAt);
}

return "There Are Currently {$fl} Freeleech Torrents On ".config('other.title').'!';
return sprintf('There Are Currently %s Freeleech Torrents On ', $fl).config('other.title').'!';
}

/**
Expand All @@ -190,7 +190,7 @@ public function getDoubleUpload($duration = 'default')
cache()->put('nerdbot-doubleup', $du, $this->expiresAt);
}

return "There Are Currently {$du} Double Upload Torrents On ".config('other.title').'!';
return sprintf('There Are Currently %s Double Upload Torrents On ', $du).config('other.title').'!';
}

/**
Expand All @@ -208,7 +208,7 @@ public function getPeers($duration = 'default')
cache()->put('nerdbot-peers', $peers, $this->expiresAt);
}

return "Currently There Are {$peers} Peers On ".config('other.title').'!';
return sprintf('Currently There Are %s Peers On ', $peers).config('other.title').'!';
}

/**
Expand All @@ -226,7 +226,7 @@ public function getBans($duration = 'default')
cache()->put('nerdbot-bans', $bans, $this->expiresAt);
}

return "In The Last 24 Hours {$bans} Users Have Been Banned From ".config('other.title').'!';
return sprintf('In The Last 24 Hours %s Users Have Been Banned From ', $bans).config('other.title').'!';
}

/**
Expand All @@ -244,7 +244,7 @@ public function getWarnings($duration = 'default')
cache()->put('nerdbot-warnings', $warnings, $this->expiresAt);
}

return "In The Last 24 Hours {$warnings} Hit and Run Warnings Have Been Issued On ".config('other.title').'!';
return sprintf('In The Last 24 Hours %s Hit and Run Warnings Have Been Issued On ', $warnings).config('other.title').'!';
}

/**
Expand All @@ -262,7 +262,7 @@ public function getUploads($duration = 'default')
cache()->put('nerdbot-uploads', $uploads, $this->expiresAt);
}

return "In The Last 24 Hours {$uploads} Torrents Have Been Uploaded To ".config('other.title').'!';
return sprintf('In The Last 24 Hours %s Torrents Have Been Uploaded To ', $uploads).config('other.title').'!';
}

/**
Expand All @@ -280,7 +280,7 @@ public function getLogins($duration = 'default')
cache()->put('nerdbot-logins', $logins, $this->expiresAt);
}

return "In The Last 24 Hours {$logins} Unique Users Have Logged Into ".config('other.title').'!';
return sprintf('In The Last 24 Hours %s Unique Users Have Logged Into ', $logins).config('other.title').'!';
}

/**
Expand All @@ -298,7 +298,7 @@ public function getRegistrations($duration = 'default')
cache()->put('nerdbot-users', $users, $this->expiresAt);
}

return "In The Last 24 Hours {$users} Users Have Registered To ".config('other.title').'!';
return sprintf('In The Last 24 Hours %s Users Have Registered To ', $users).config('other.title').'!';
}

/**
Expand Down Expand Up @@ -354,7 +354,7 @@ public function putDonate($amount = 0, $note = '')
$output = implode(' ', $note);
$v = validator(['bot_id' => $this->bot->id, 'amount'=> $amount, 'note'=> $output], [
'bot_id' => 'required|exists:bots,id|max:999',
'amount' => "required|numeric|min:1|max:{$this->target->seedbonus}",
'amount' => sprintf('required|numeric|min:1|max:%s', $this->target->seedbonus),
'note' => 'required|string',
]);
if ($v->passes()) {
Expand Down
4 changes: 2 additions & 2 deletions app/Bots/SystemBot.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public function putGift($receiver = '', $amount = 0, $note = '')
$output = implode(' ', $note);
$v = validator(['receiver' => $receiver, 'amount'=> $amount, 'note'=> $output], [
'receiver' => 'required|string|exists:users,username',
'amount' => "required|numeric|min:1|max:{$this->target->seedbonus}",
'amount' => sprintf('required|numeric|min:1|max:%s', $this->target->seedbonus),
'note' => 'required|string',
]);
if ($v->passes()) {
Expand Down Expand Up @@ -133,7 +133,7 @@ public function putGift($receiver = '', $amount = 0, $note = '')
$recipient_url = hrefProfile($recipient);

$this->chat->systemMessage(
"[url={$profile_url}]{$this->target->username}[/url] has gifted {$value} BON to [url={$recipient_url}]{$recipient->username}[/url]"
sprintf('[url=%s]%s[/url] has gifted %s BON to [url=%s]%s[/url]', $profile_url, $this->target->username, $value, $recipient_url, $recipient->username)
);

return 'Your gift to '.$recipient->username.' for '.$amount.' BON has been sent!';
Expand Down
4 changes: 2 additions & 2 deletions app/Console/Commands/AutoGraveyard.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,15 @@ public function handle()
$appurl = config('app.url');

$this->chat->systemMessage(
"Ladies and Gents, [url={$appurl}/users/{$user->username}]{$user->username}[/url] has successfully resurrected [url={$appurl}/torrents/{$torrent->id}]{$torrent->name}[/url]. :zombie:"
sprintf('Ladies and Gents, [url=%s/users/%s]%s[/url] has successfully resurrected [url=%s/torrents/%s]%s[/url]. :zombie:', $appurl, $user->username, $user->username, $appurl, $torrent->id, $torrent->name)
);

// Send Private Message
$pm = new PrivateMessage();
$pm->sender_id = 1;
$pm->receiver_id = $user->id;
$pm->subject = 'Successful Graveyard Resurrection';
$pm->message = "You have successfully resurrected [url={$appurl}/torrents/".$torrent->id.']'.$torrent->name.'[/url] :zombie: ! Thank you for bringing a torrent back from the dead! Enjoy the freeleech tokens!
$pm->message = sprintf('You have successfully resurrected [url=%s/torrents/', $appurl).$torrent->id.']'.$torrent->name.'[/url] :zombie: ! Thank you for bringing a torrent back from the dead! Enjoy the freeleech tokens!
[color=red][b]THIS IS AN AUTOMATED SYSTEM MESSAGE, PLEASE DO NOT REPLY![/b][/color]';
$pm->save();
}
Expand Down
28 changes: 14 additions & 14 deletions app/Console/Commands/AutoNerdStat.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,25 +123,25 @@ public function handle()

// Select A Random Nerd Stat
$statArray = [
"In The Last 24 Hours [color=#93c47d][b]{$logins}[/b][/color] Unique Users Have Logged Into ".config('other.title').'!',
"In The Last 24 Hours [color=#93c47d][b]{$uploads}[/b][/color] Torrents Have Been Uploaded To ".config('other.title').'!',
"In The Last 24 Hours [color=#93c47d][b]{$users}[/b][/color] Users Have Registered To ".config('other.title').'!',
"There Are Currently [color=#93c47d][b]{$fl}[/b][/color] Freeleech Torrents On ".config('other.title').'!',
"There Are Currently [color=#93c47d][b]{$du}[/b][/color] Double Upload Torrents On ".config('other.title').'!',
"Currently [url={$seeded_url}]{$seeded->name}[/url] Is The Best Seeded Torrent On ".config('other.title').'!',
"Currently [url={$leeched_url}]{$leeched->name}[/url] Is The Most Leeched Torrent On ".config('other.title').'!',
"Currently [url={$snatched_url}]{$snatched->name}[/url] Is The Most Snatched Torrent On ".config('other.title').'!',
"Currently [url={$banker_url}]{$banker->username}[/url] Is The Top BON Holder On ".config('other.title').'!',
"Currently There Are [color=#93c47d][b]{$peers}[/b][/color] Peers On ".config('other.title').'!',
"In The Last 24 Hours [color=#dd7e6b][b]{$bans}[/b][/color] Users Have Been Banned From ".config('other.title').'!',
"In The Last 24 Hours [color=#dd7e6b][b]{$warnings}[/b][/color] Hit and Run Warnings Have Been Issued On ".config('other.title').'!',
config('other.title')." Birthday Is [b]{$bday}[/b]!",
sprintf('In The Last 24 Hours [color=#93c47d][b]%s[/b][/color] Unique Users Have Logged Into ', $logins).config('other.title').'!',
sprintf('In The Last 24 Hours [color=#93c47d][b]%s[/b][/color] Torrents Have Been Uploaded To ', $uploads).config('other.title').'!',
sprintf('In The Last 24 Hours [color=#93c47d][b]%s[/b][/color] Users Have Registered To ', $users).config('other.title').'!',
sprintf('There Are Currently [color=#93c47d][b]%s[/b][/color] Freeleech Torrents On ', $fl).config('other.title').'!',
sprintf('There Are Currently [color=#93c47d][b]%s[/b][/color] Double Upload Torrents On ', $du).config('other.title').'!',
sprintf('Currently [url=%s]%s[/url] Is The Best Seeded Torrent On ', $seeded_url, $seeded->name).config('other.title').'!',
sprintf('Currently [url=%s]%s[/url] Is The Most Leeched Torrent On ', $leeched_url, $leeched->name).config('other.title').'!',
sprintf('Currently [url=%s]%s[/url] Is The Most Snatched Torrent On ', $snatched_url, $snatched->name).config('other.title').'!',
sprintf('Currently [url=%s]%s[/url] Is The Top BON Holder On ', $banker_url, $banker->username).config('other.title').'!',
sprintf('Currently There Are [color=#93c47d][b]%s[/b][/color] Peers On ', $peers).config('other.title').'!',
sprintf('In The Last 24 Hours [color=#dd7e6b][b]%s[/b][/color] Users Have Been Banned From ', $bans).config('other.title').'!',
sprintf('In The Last 24 Hours [color=#dd7e6b][b]%s[/b][/color] Hit and Run Warnings Have Been Issued On ', $warnings).config('other.title').'!',
config('other.title').sprintf(' Birthday Is [b]%s[/b]!', $bday),
config('other.title').' Is King!',
];
$selected = mt_rand(0, count($statArray) - 1);

// Auto Shout Nerd Stat
$this->chat->systemMessage("{$statArray[$selected]}", 2);
$this->chat->systemMessage(sprintf('%s', $statArray[$selected]), 2);
}
}
}
4 changes: 2 additions & 2 deletions app/Console/Commands/AutoPreWarning.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ public function handle()
$pm->sender_id = 1;
$pm->receiver_id = $pre->user->id;
$pm->subject = 'Hit and Run Warning Incoming';
$pm->message = 'You have received a automated [b]PRE-WARNING PM[/b] from the system because [b]you have been disconnected for '.config('hitrun.prewarn')." days on Torrent {$pre->torrent->name}
and have not yet met the required seedtime rules set by ".config('other.title').". If you fail to seed it within {$timeleft} day(s) you will receive a automated WARNING which will last ".config('hitrun.expire').' days![/b]
$pm->message = 'You have received a automated [b]PRE-WARNING PM[/b] from the system because [b]you have been disconnected for '.config('hitrun.prewarn').sprintf(' days on Torrent %s
and have not yet met the required seedtime rules set by ', $pre->torrent->name).config('other.title').sprintf('. If you fail to seed it within %s day(s) you will receive a automated WARNING which will last ', $timeleft).config('hitrun.expire').' days![/b]
[color=red][b] THIS IS AN AUTOMATED SYSTEM MESSAGE, PLEASE DO NOT REPLY![/b][/color]';
$pm->save();

Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/AutoRecycleClaimedTorrentRequests.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function handle()
if ($requestClaim) {
$tr_url = hrefRequest($torrentRequest);
$this->chat->systemMessage(
"[url={$tr_url}]{$torrentRequest->name}[/url] claim has been reset due to not being filled within 7 days."
sprintf('[url=%s]%s[/url] claim has been reset due to not being filled within 7 days.', $tr_url, $torrentRequest->name)
);

$requestClaim->delete();
Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/AutoRemoveFeaturedTorrent.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function handle()
$appurl = config('app.url');

$this->chat->systemMessage(
"Ladies and Gents, [url={$appurl}/torrents/{$torrent->id}]{$torrent->name}[/url] is no longer featured. :poop:"
sprintf('Ladies and Gents, [url=%s/torrents/%s]%s[/url] is no longer featured. :poop:', $appurl, $torrent->id, $torrent->name)
);

// Delete The Record From DB
Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/AutoWarning.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function handle()
$warning->user_id = $hr->user->id;
$warning->warned_by = '1';
$warning->torrent = $hr->torrent->id;
$warning->reason = "Hit and Run Warning For Torrent {$hr->torrent->name}";
$warning->reason = sprintf('Hit and Run Warning For Torrent %s', $hr->torrent->name);
$warning->expires_on = $current->copy()->addDays(config('hitrun.expire'));
$warning->active = '1';
$warning->save();
Expand Down
Loading

0 comments on commit 610a5f7

Please sign in to comment.