-
-
Notifications
You must be signed in to change notification settings - Fork 364
/
autoPreWarning.php
78 lines (68 loc) · 2.84 KB
/
autoPreWarning.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
/**
* NOTICE OF LICENSE
*
* UNIT3D is open-sourced software licensed under the GNU General Public License v3.0
* The details is bundled with this project in the file LICENSE.txt.
*
* @project UNIT3D
* @license https://choosealicense.com/licenses/gpl-3.0/ GNU General Public License v3.0
* @author HDVinnie
*/
namespace App\Console\Commands;
use App\Torrent;
use App\History;
use App\PrivateMessage;
use App\User;
use App\Warning;
use Carbon\Carbon;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
class autoPreWarning extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'autoPreWarning';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Automatically Sends Pre Warning PM To Users';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
if (config('hitrun.enabled') == true) {
$current = new Carbon();
$prewarn = History::with(['user', 'torrent'])
->where('actual_downloaded', '>', 0)
->where('active', '=', 0)
->where('seedtime', '<=', config('hitrun.seedtime'))
->where('updated_at', '<', $current->copy()->subDays(config('hitrun.prewarn'))->toDateTimeString())
->get();
foreach ($prewarn as $pre) {
if (!$pre->user->group->is_immune) {
if ($pre->actual_downloaded > ($pre->torrent->size * (config('hitrun.buffer') / 100))) {
$exsist = Warning::where('torrent', '=', $pre->torrent->id)->where('user_id', '=', $pre->user->id)->first();
// Send Pre Warning PM If Actual Warning Doesnt Already Exsist
if (!$exsist) {
$timeleft = config('hitrun.grace') - config('hitrun.prewarn');
// Send Prewarning PM To The Offender
PrivateMessage::create(['sender_id' => "1", 'reciever_id' => $pre->user->id, 'subject' => "Hit and Run Warning Incoming", '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 . "
If you fail to seed it within " . $timeleft . " day(s) you will recieve a automated WARNING which will last " . config('hitrun.expire') ." days![/b]
[color=red][b] THIS IS AN AUTOMATED SYSTEM MESSAGE, PLEASE DO NOT REPLY![/b][/color]"]);
}
unset($exist);
}
}
}
}
}
}