(Update) Commands

- Renamed commands to make them more understanding
- Removed hardcode and linked instead to hitrun config file
- Fixed sender_id in multiple cases
This commit is contained in:
HDVinnie
2017-12-14 20:57:47 -05:00
parent 4d8b0a8ad3
commit 3e02efbc59
8 changed files with 40 additions and 36 deletions
+3 -7
View File
@@ -46,26 +46,22 @@ class autoBan extends Command
*/
public function handle()
{
$bans = Warning::with('warneduser')->select(DB::raw('user_id, count(*) as value'))->where('active', '=', '1')->groupBy('user_id')->having('value', '>=', '3')->get();
$bans = Warning::with('warneduser')->select(DB::raw('user_id, count(*) as value'))->where('active', '=', '1')->groupBy('user_id')->having('value', '>=', config('hitrun.buffer'))->get();
foreach ($bans as $ban) {
if ($ban->warneduser->group_id != 5 && !$ban->warneduser->group->is_immune) {
// If User Has 3 or More Active Warnings Ban Set The Users Group To Banned
// If User Has x or More Active Warnings Ban Set The Users Group To Banned
$ban->warneduser->group_id = 5;
$ban->warneduser->save();
// Log The Ban To Ban Log
$ban = new Ban([
"owned_by" => $ban->warneduser->id,
"created_by" => "0",
"created_by" => "1",
"ban_reason" => "Warning Limit Reached, has " . $ban->value . " warnings.",
"unban_reason" => "",
]);
$ban->save();
// Email The User That They Have Been Banned For Hitting Warning Limits
//Mail::to($user->email, $user->username)->send(new BanUser($user, $ban));
}
}
}
+9 -9
View File
@@ -63,7 +63,7 @@ class autoGroup extends Command
$user->can_invite = 0;
$user->can_download = 0;
$user->save();
//PrivateMessage::create(['sender_id' => "0", 'reciever_id' => $user->id, 'subject' => "Sad News My Friend!", 'message' => "You have been demoted to Leech group. Your ratio dropped below 0.2. So now you have been placed in Leech Group and your download rights, invite rights and request rights have been revoked. Please seed and use bon to bring ratio back up! [color=red][b]THIS IS AN AUTOMATED SYSTEM MESSAGE, PLEASE DO NOT REPLY![/b][/color]"]);
//PrivateMessage::create(['sender_id' => "1", 'reciever_id' => $user->id, 'subject' => "Sad News My Friend!", 'message' => "You have been demoted to Leech group. Your ratio dropped below 0.2. So now you have been placed in Leech Group and your download rights, invite rights and request rights have been revoked. Please seed and use bon to bring ratio back up! [color=red][b]THIS IS AN AUTOMATED SYSTEM MESSAGE, PLEASE DO NOT REPLY![/b][/color]"]);
}
//Member >= 0 but < 1TB and ratio above sites minimum
if ($user->uploaded >= 0 && $user->getRatio() > Config::get('other.ratio') && $user->group_id != 3) {
@@ -72,51 +72,51 @@ class autoGroup extends Command
$user->can_request = 1;
$user->can_invite = 1;
$user->save();
//PrivateMessage::create(['sender_id' => "0", 'reciever_id' => $user->id, 'subject' => "Group Change", 'message' => "You group/rank has been changed! [color=red][b]THIS IS AN AUTOMATED SYSTEM MESSAGE, PLEASE DO NOT REPLY![/b][/color]"]);
//PrivateMessage::create(['sender_id' => "1", 'reciever_id' => $user->id, 'subject' => "Group Change", 'message' => "You group/rank has been changed! [color=red][b]THIS IS AN AUTOMATED SYSTEM MESSAGE, PLEASE DO NOT REPLY![/b][/color]"]);
}
//BluMember >= 1TB but < 5TB and account 1 month old
if ($user->uploaded >= 1073741824000 && $user->uploaded < 1073741824000 * 5 && $user->created_at < $current->copy()->subDays(30)->toDateTimeString() && $user->group_id != 11) {
$user->group_id = 11;
$user->save();
//PrivateMessage::create(['sender_id' => "0", 'reciever_id' => $user->id, 'subject' => "Group Change", 'message' => "You group/rank has been changed! [color=red][b]THIS IS AN AUTOMATED SYSTEM MESSAGE, PLEASE DO NOT REPLY![/b][/color]"]);
//PrivateMessage::create(['sender_id' => "1", 'reciever_id' => $user->id, 'subject' => "Group Change", 'message' => "You group/rank has been changed! [color=red][b]THIS IS AN AUTOMATED SYSTEM MESSAGE, PLEASE DO NOT REPLY![/b][/color]"]);
}
//BluMaster >= 5TB but < 20TB and account 1 month old
if ($user->uploaded >= 1073741824000 * 5 && $user->uploaded < 1073741824000 * 20 && $user->created_at < $current->copy()->subDays(30)->toDateTimeString() && $user->group_id != 12) {
$user->group_id = 12;
$user->save();
//PrivateMessage::create(['sender_id' => "0", 'reciever_id' => $user->id, 'subject' => "Group Change", 'message' => "You group/rank has been changed! [color=red][b]THIS IS AN AUTOMATED SYSTEM MESSAGE, PLEASE DO NOT REPLY![/b][/color]"]);
//PrivateMessage::create(['sender_id' => "1", 'reciever_id' => $user->id, 'subject' => "Group Change", 'message' => "You group/rank has been changed! [color=red][b]THIS IS AN AUTOMATED SYSTEM MESSAGE, PLEASE DO NOT REPLY![/b][/color]"]);
}
//BluExtremist >= 20TB but < 50TB and account 3 month old
if ($user->uploaded >= 1073741824000 * 20 && $user->uploaded < 1073741824000 * 50 && $user->created_at < $current->copy()->subDays(90)->toDateTimeString() && $user->group_id != 13) {
$user->group_id = 13;
$user->save();
//PrivateMessage::create(['sender_id' => "0", 'reciever_id' => $user->id, 'subject' => "Group Change", 'message' => "You group/rank has been changed! [color=red][b]THIS IS AN AUTOMATED SYSTEM MESSAGE, PLEASE DO NOT REPLY![/b][/color]"]);
//PrivateMessage::create(['sender_id' => "1", 'reciever_id' => $user->id, 'subject' => "Group Change", 'message' => "You group/rank has been changed! [color=red][b]THIS IS AN AUTOMATED SYSTEM MESSAGE, PLEASE DO NOT REPLY![/b][/color]"]);
}
//BluLegend >= 50TB but < 100TB and account 6 month old
if ($user->uploaded >= 1073741824000 * 50 && $user->uploaded < 1073741824000 * 100 && $user->created_at < $current->copy()->subDays(180)->toDateTimeString() && $user->group_id != 14) {
$user->group_id = 14;
$user->save();
//PrivateMessage::create(['sender_id' => "0", 'reciever_id' => $user->id, 'subject' => "Group Change", 'message' => "You group/rank has been changed! [color=red][b]THIS IS AN AUTOMATED SYSTEM MESSAGE, PLEASE DO NOT REPLY![/b][/color]"]);
//PrivateMessage::create(['sender_id' => "1", 'reciever_id' => $user->id, 'subject' => "Group Change", 'message' => "You group/rank has been changed! [color=red][b]THIS IS AN AUTOMATED SYSTEM MESSAGE, PLEASE DO NOT REPLY![/b][/color]"]);
}
//Blutopian >= 100TB and account 1 year old
if ($user->uploaded >= 1073741824000 * 100 && $user->created_at < $current->copy()->subDays(365)->toDateTimeString() && $user->group_id != 16) {
$user->group_id = 16;
$user->save();
//PrivateMessage::create(['sender_id' => "0", 'reciever_id' => $user->id, 'subject' => "Group Change", 'message' => "You group/rank has been changed! [color=red][b]THIS IS AN AUTOMATED SYSTEM MESSAGE, PLEASE DO NOT REPLY![/b][/color]"]);
//PrivateMessage::create(['sender_id' => "1", 'reciever_id' => $user->id, 'subject' => "Group Change", 'message' => "You group/rank has been changed! [color=red][b]THIS IS AN AUTOMATED SYSTEM MESSAGE, PLEASE DO NOT REPLY![/b][/color]"]);
}
//BluSeeder seeding >= 150 and account 1 month old and seedtime average 30 days or better
if ($user->getSeeding() >= 150 && round($user->getTotalSeedTime() / max(1, $hiscount)) > 2592000 && $user->created_at < $current->copy()->subDays(30)->toDateTimeString() && $user->group_id != 17) {
$user->group_id = 17;
$user->save();
//PrivateMessage::create(['sender_id' => "0", 'reciever_id' => $user->id, 'subject' => "Group Change", 'message' => "You group/rank has been changed! [color=red][b]THIS IS AN AUTOMATED SYSTEM MESSAGE, PLEASE DO NOT REPLY![/b][/color]"]);
//PrivateMessage::create(['sender_id' => "1", 'reciever_id' => $user->id, 'subject' => "Group Change", 'message' => "You group/rank has been changed! [color=red][b]THIS IS AN AUTOMATED SYSTEM MESSAGE, PLEASE DO NOT REPLY![/b][/color]"]);
}
//BluArchivist seeding >= 300 and account 3 month old and seedtime average 60 days or better
if ($user->getSeeding() >= 300 && round($user->getTotalSeedTime() / max(1, $hiscount)) > 2592000 * 2 && $user->created_at < $current->copy()->subDays(90)->toDateTimeString() && $user->group_id != 18) {
$user->group_id = 18;
$user->save();
//PrivateMessage::create(['sender_id' => "0", 'reciever_id' => $user->id, 'subject' => "Group Change", 'message' => "You group/rank has been changed! [color=red][b]THIS IS AN AUTOMATED SYSTEM MESSAGE, PLEASE DO NOT REPLY![/b][/color]"]);
//PrivateMessage::create(['sender_id' => "1", 'reciever_id' => $user->id, 'subject' => "Group Change", 'message' => "You group/rank has been changed! [color=red][b]THIS IS AN AUTOMATED SYSTEM MESSAGE, PLEASE DO NOT REPLY![/b][/color]"]);
}
}
}
+11 -4
View File
@@ -45,8 +45,14 @@ class autoWarning extends Command
*/
public function handle()
{
if (config('hitrun.enabled') == true) {
$current = new Carbon();
$hitrun = History::with(['user', 'torrent'])->where('actual_downloaded', '>', 0)->where('active', '=', 0)->where('seedtime', '<=', 604800)->where('updated_at', '<', $current->copy()->subDays(3)->toDateTimeString())->get();
$hitrun = History::with(['user', 'torrent'])
->where('actual_downloaded', '>', 0)
->where('active', '=', 0)
->where('seedtime', '<=', config('hitrun.seedtime'))
->where('updated_at', '<', $current->copy()->subDays(config('hitrun.grace'))->toDateTimeString())
->get();
foreach ($hitrun as $hr) {
if (!$hr->user->group->is_immune) {
@@ -58,10 +64,10 @@ class autoWarning extends Command
if (!$exsist) {
$warning = new Warning();
$warning->user_id = $hr->user->id;
$warning->warned_by = "0";
$warning->warned_by = "1";
$warning->torrent = $hr->torrent->id;
$warning->reason = "Hit and Run Warning For Torrent {$hr->torrent->name}";
$warning->expires_on = $current->copy()->addDays(14);
$warning->expires_on = $current->copy()->addDays(config('hitrun.expire'));
$warning->active = "1";
$warning->save();
@@ -70,7 +76,7 @@ class autoWarning extends Command
$hr->user->save();
// Send PM To The Offender
PrivateMessage::create(['sender_id' => "0", 'reciever_id' => $hr->user->id, 'subject' => "Hit and Run Warning Recieved", 'message' => "You have received a automated [b]WARNING[/b] from the system because [b]you failed to follow the Hit and Run rules in relation to Torrent " . $hr->torrent->name . "[/b][color=red][b]THIS IS AN AUTOMATED SYSTEM MESSAGE, PLEASE DO NOT REPLY![/b][/color]"]);
PrivateMessage::create(['sender_id' => "1", 'reciever_id' => $hr->user->id, 'subject' => "Hit and Run Warning Recieved", 'message' => "You have received a automated [b]WARNING[/b] from the system because [b]you failed to follow the Hit and Run rules in relation to Torrent " . $hr->torrent->name . "[/b][color=red][b]THIS IS AN AUTOMATED SYSTEM MESSAGE, PLEASE DO NOT REPLY![/b][/color]"]);
}
unset($exist);
@@ -78,4 +84,5 @@ class autoWarning extends Command
}
}
}
}
}
@@ -19,21 +19,21 @@ use Carbon\Carbon;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
class removeWarning extends Command
class deactivateWarning extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'removeWarning';
protected $signature = 'deactivateWarning';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Automatically Remove User Warnings If Expired';
protected $description = 'Automatically Deactivates User Warnings If Expired';
/**
* Execute the console command.
@@ -51,7 +51,7 @@ class removeWarning extends Command
$warning->save();
// PM User That Warning Has Expired
PrivateMessage::create(['sender_id' => "0", 'reciever_id' => $warning->warneduser->id, 'subject' => "Hit and Run Warning Removed", 'message' => "The [b]WARNING[/b] you received relating to Torrent " . $warning->torrenttitle->name . " has expired! Try not to get more! [color=red][b]THIS IS AN AUTOMATED SYSTEM MESSAGE, PLEASE DO NOT REPLY![/b][/color]"]);
PrivateMessage::create(['sender_id' => "1", 'reciever_id' => $warning->warneduser->id, 'subject' => "Hit and Run Warning Deactivated", 'message' => "The [b]WARNING[/b] you received relating to Torrent " . $warning->torrenttitle->name . " has expired! Try not to get more! [color=red][b]THIS IS AN AUTOMATED SYSTEM MESSAGE, PLEASE DO NOT REPLY![/b][/color]"]);
}
}
}
+1 -1
View File
@@ -50,7 +50,7 @@ class removeUserFreeleech extends Command
$pfl->delete();
// PM User That Warning Has Expired
PrivateMessage::create(['sender_id' => "0", 'reciever_id' => $pfl->user_id, 'subject' => "Personal 24 Hour Freeleech", 'message' => "Your [b]Personal 24 Hour Freeleech[/b] has expired! Feel free to reenable it in the BON Store! [color=red][b]THIS IS AN AUTOMATED SYSTEM MESSAGE, PLEASE DO NOT REPLY![/b][/color]"]);
PrivateMessage::create(['sender_id' => "1", 'reciever_id' => $pfl->user_id, 'subject' => "Personal 24 Hour Freeleech", 'message' => "Your [b]Personal 24 Hour Freeleech[/b] has expired! Feel free to reenable it in the BON Store! [color=red][b]THIS IS AN AUTOMATED SYSTEM MESSAGE, PLEASE DO NOT REPLY![/b][/color]"]);
}
}
}
@@ -19,21 +19,21 @@ use App\User;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
class denyRights extends Command
class revokePermissions extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'denyRights';
protected $signature = 'revokePermissions';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Revokes download rights of users who have above x active warnings';
protected $description = 'Revokes certain permissions of users who have above x active warnings';
/**
* Execute the console command.
@@ -47,17 +47,17 @@ class denyRights extends Command
User::where('group_id', '=', '5')->update(['can_download' => '0', 'can_request' => '0']);
User::where('group_id', '=', '15')->update(['can_download' => '0', 'can_request' => '0']);
$warning = Warning::with('warneduser')->select(DB::raw('user_id, count(*) as value'))->where('active', '=', '1')->groupBy('user_id')->having('value', '>=', '2')->get();
$warning = Warning::with('warneduser')->select(DB::raw('user_id, count(*) as value'))->where('active', '=', '1')->groupBy('user_id')->having('value', '>=', config('hitrun.revoke'))->get();
foreach ($warning as $deny) {
if ($deny->warneduser->can_download == 1 && $deny->warneduser->can_request == 1) {
//Disable the user's can_download and can_request rights
//Disable the user's can_download and can_request permissions
$deny->warneduser->can_download = 0;
$deny->warneduser->can_request = 0;
$deny->warneduser->save();
//Private message notifiing users of their rights being revoked.
//PrivateMessage::create(['sender_id' => "0", 'reciever_id' => $deny->warneduser->id, 'subject' => "Rights Revoked", 'message' => "Due to your active warnings, Your download and request rights have been revoked."]);
//PrivateMessage::create(['sender_id' => "1", 'reciever_id' => $deny->warneduser->id, 'subject' => "Rights Revoked", 'message' => "Due to your active warnings, Your download and request rights have been revoked."]);
}
}
}
+2 -2
View File
@@ -18,8 +18,8 @@ class Kernel extends ConsoleKernel
\App\Console\Commands\bonAllocation::class,
\App\Console\Commands\autoSeedbox::class,
\App\Console\Commands\autoWarning::class,
\App\Console\Commands\removeWarning::class,
\App\Console\Commands\denyRights::class,
\App\Console\Commands\deactivateWarning::class,
\App\Console\Commands\revokePermissions::class,
\App\Console\Commands\autoBan::class,
\App\Console\Commands\FlushPeers::class,
\App\Console\Commands\autoGroup::class,
+4 -3
View File
@@ -47,14 +47,14 @@ return [
/*
|--------------------------------------------------------------------------
| Download Rights Disable
| Revoke Permissions
|--------------------------------------------------------------------------
|
| Max Warnings Before Download Rights Are Disabled
| Max Warnings Before Certain Permissions Are Revoked
|
*/
'download_disable' => 2,
'revoke' => 2,
/*
|--------------------------------------------------------------------------
@@ -89,4 +89,5 @@ return [
*/
'expire' => 14,
];