(Update)[Chat 2.0] Updated system messages

This commit is contained in:
Poppabear
2018-05-08 21:05:53 -04:00
parent 7ea7c05b64
commit 0fd8f5a9ef
4 changed files with 101 additions and 52 deletions
@@ -13,6 +13,7 @@
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Repositories\ChatRepository;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Mail;
@@ -32,6 +33,13 @@ use Cache;
class RegisterController extends Controller
{
private $chat;
public function __construct(ChatRepository $chat)
{
$this->chat = $chat;
}
public function register(Request $request, $code = null)
{
$current = Carbon::now();
@@ -88,9 +96,11 @@ class RegisterController extends Controller
]);
$this->dispatch(new SendActivationMail($user, $token));
$appurl = config('app.url');
// Post To Chatbox
Message::create(['user' => "1", 'chatroom_id' => "1", 'message' => "Welcome [url={$appurl}/" . $user->username . "." . $user->id . "]" . $user->username . "[/url] hope you enjoy the community :rocket:"]);
$profile_url = hrefProfile($user);
$this->chat->systemMessage(
"Welcome [url={$profile_url}]{$user->username}[/url] hope you enjoy the community :rocket:"
);
// Send Welcome PM
PrivateMessage::create(['sender_id' => "1", 'reciever_id' => $user->id, 'subject' => config('welcomepm.subject'), 'message' => config('welcomepm.message')]);
+14 -3
View File
@@ -13,6 +13,7 @@
namespace App\Http\Controllers\Staff;
use App\Http\Controllers\Controller;
use App\Repositories\ChatRepository;
use Illuminate\Http\Request;
use App\Poll;
use App\Option;
@@ -23,6 +24,14 @@ use \Toastr;
class PollController extends Controller
{
private $chat;
public function __construct(ChatRepository $chat)
{
$this->chat = $chat;
}
public function polls()
{
$polls = Poll::latest()->paginate(25);
@@ -69,9 +78,11 @@ class PollController extends Controller
// Activity Log
\LogActivity::addToLog("Staff Member {$user->username} has created a new poll {$poll->title}.");
// Auto Shout
$appurl = config('app.url');
Message::create(['user_id' => "1", 'chatroom_id' => "3", 'message' => "A new poll has been created [url={$appurl}/poll/{$poll->slug}]{$poll->title}[/url] vote on it now! :slight_smile:"]);
$poll_url = hrefPoll($poll);
$this->chat->systemMessage(
"A new poll has been created [url={$poll_url}]{$poll->title}[/url] vote on it now! :slight_smile:"
);
return redirect('poll/' . $poll->slug)->with(Toastr::success('Your poll has been created.', 'Yay!', ['options']));
}
+64 -37
View File
@@ -12,6 +12,7 @@
namespace App\Http\Controllers;
use App\Repositories\ChatRepository;
use Illuminate\Http\Request;
use \DB;
use App\Category;
@@ -51,18 +52,14 @@ class TorrentController extends Controller
/**
* @var TorrentFacetedRepository
*/
private $repository;
private $faceted;
/**
* Constructs a object of type TorrentController
*
* @param $repository
*
* @return View
*/
public function __construct(TorrentFacetedRepository $repository)
private $chat;
public function __construct(TorrentFacetedRepository $faceted, ChatRepository $chat)
{
$this->repository = $repository;
$this->faceted = $faceted;
$this->chat = $chat;
view()->share('pages', Page::all());
}
@@ -108,25 +105,31 @@ class TorrentController extends Controller
*/
public function bumpTorrent($slug, $id)
{
if (auth()->user()->group->is_modo || auth()->user()->group->is_internal) {
$user = auth()->user();
if ($user->group->is_modo || $user->group->is_internal) {
$torrent = Torrent::withAnyStatus()->findOrFail($id);
$torrent->created_at = Carbon::now();
$torrent->save();
// Activity Log
\LogActivity::addToLog("Staff Member " . auth()->user()->username . " has bumped torrent, ID: {$torrent->id} NAME: {$torrent->name} .");
\LogActivity::addToLog("Staff Member " . $user->username . " has bumped torrent, ID: {$torrent->id} NAME: {$torrent->name} .");
// Announce To Chat
$appurl = config('app.url');
Message::create(['user_id' => "1", 'chatroom_id' => "3", 'message' => ":warning: Attention, [url={$appurl}/torrents/{$torrent->slug}.{$torrent->id}]{$torrent->name}[/url] has been bumped to top by [url={$appurl}/" . auth()->user()->username . "." . auth()->user()->id . "]" . auth()->user()->username . "[/url]! It could use more seeds! :warning:"]);
$torrent_url = hrefTorrent($torrent);
$profile_url = hrefProfile($user);
$this->chat->systemMessage(
":warning: Attention, [url={$torrent_url}]{$torrent->name}[/url] has been bumped to top by [url={$profile_url}]{$user->username}[/url]! It could use more seeds! :warning:"
);
// Announce To IRC
if (config('irc-bot.enabled') == true) {
$appname = config('app.name');
$bot = new IRCAnnounceBot();
$bot->message("#announce", "[" . $appname . "] User " . auth()->user()->username . " has bumped " . $torrent->name . " , it could use more seeds!");
$bot->message("#announce", "[" . $appname . "] User " . $user->username . " has bumped " . $torrent->name . " , it could use more seeds!");
$bot->message("#announce", "[Category: " . $torrent->category->name . "] [Type: " . $torrent->type . "] [Size:" . $torrent->getSize() . "]");
$bot->message("#announce", "[Link: {$appurl}/torrents/" . $slug . "." . $id . "]");
$bot->message("#announce", "[Link: $torrent_url]");
}
return redirect()->route('torrent', ['slug' => $torrent->slug, 'id' => $torrent->id])->with(Toastr::success('Torrent Has Been Bumped To Top Successfully!', 'Yay!', ['options']));
@@ -351,7 +354,7 @@ class TorrentController extends Controller
$torrents = Torrent::query();
$alive = Torrent::where('seeders', '>=', 1)->count();
$dead = Torrent::where('seeders', 0)->count();
$repository = $this->repository;
$repository = $this->faceted;
return view('torrent.torrents', compact('repository', 'torrents', 'user', 'alive', 'dead'));
}
@@ -632,22 +635,30 @@ class TorrentController extends Controller
*/
public function grantFL($slug, $id)
{
if (auth()->user()->group->is_modo || auth()->user()->group->is_internal) {
$user = auth()->user();
if ($user->group->is_modo || $user->group->is_internal) {
$torrent = Torrent::withAnyStatus()->findOrFail($id);
$appurl = config('app.url');
$torrent_url = hrefTorrent($torrent);
if ($torrent->free == 0) {
$torrent->free = "1";
// Announce To Chat
Message::create(['user_id' => "1", 'chatroom_id' => "3", 'message' => "Ladies and Gents, [url={$appurl}/torrents/{$torrent->slug}.{$torrent->id}]{$torrent->name}[/url] has been granted 100% FreeLeech! Grab It While You Can! :fire:"]);
$this->chat->systemMessage(
"Ladies and Gents, [url={$torrent_url}]{$torrent->name}[/url] has been granted 100% FreeLeech! Grab It While You Can! :fire:"
);
} else {
$torrent->free = "0";
// Announce To Chat
Message::create(['user_id' => "1", 'chatroom_id' => "3", 'message' => "Ladies and Gents, [url={$appurl}/torrents/{$torrent->slug}.{$torrent->id}]{$torrent->name}[/url] has been revoked of its 100% FreeLeech! :poop:"]);
$this->chat->systemMessage(
"Ladies and Gents, [url={$torrent_url}]{$torrent->name}[/url] has been revoked of its 100% FreeLeech! :poop:"
);
}
$torrent->save();
// Activity Log
\LogActivity::addToLog("Staff Member " . auth()->user()->username . " has granted freeleech on torrent, ID: {$torrent->id} NAME: {$torrent->name} .");
\LogActivity::addToLog("Staff Member " . $user->username . " has granted freeleech on torrent, ID: {$torrent->id} NAME: {$torrent->name} .");
return redirect()->route('torrent', ['slug' => $torrent->slug, 'id' => $torrent->id])->with(Toastr::success('Torrent FL Has Been Adjusted!', 'Yay!', ['options']));
} else {
@@ -667,7 +678,9 @@ class TorrentController extends Controller
*/
public function grantFeatured($slug, $id)
{
if (auth()->user()->group->is_modo || auth()->user()->group->is_internal) {
$user = auth()->user();
if ($user->group->is_modo || $user->group->is_internal) {
$torrent = Torrent::withAnyStatus()->findOrFail($id);
if ($torrent->featured == 0) {
$torrent->free = "1";
@@ -679,9 +692,12 @@ class TorrentController extends Controller
]);
$featured->save();
// Announce To Chat
$appurl = config('app.url');
Message::create(['user_id' => "1", 'chatroom_id' => "3", 'message' => "Ladies and Gents, [url={$appurl}/torrents/{$torrent->slug}.{$torrent->id}]{$torrent->name}[/url] has been added to the Featured Torrents Slider by [url={$appurl}/" . auth()->user()->username . "." . auth()->user()->id . "]" . auth()->user()->username . "[/url]! Grab It While You Can! :fire:"]);
$torrent_url = hrefTorrent($torrent);
$profile_url = hrefProfile($user);
$this->chat->systemMessage(
"Ladies and Gents, [url={$torrent_url}]{$torrent->name}[/url] has been added to the Featured Torrents Slider by [url={$profile_url}]{$user->username}[/url]! Grab It While You Can! :fire:"
);
// Activity Log
\LogActivity::addToLog("Staff Member " . auth()->user()->username . " has featured torrent, ID: {$torrent->id} NAME: {$torrent->name} .");
@@ -708,22 +724,29 @@ class TorrentController extends Controller
*/
public function grantDoubleUp($slug, $id)
{
if (auth()->user()->group->is_modo || auth()->user()->group->is_internal) {
$user = auth()->user();
if ($user->group->is_modo || $user->group->is_internal) {
$torrent = Torrent::withAnyStatus()->findOrFail($id);
$appurl = config('app.url');
$torrent_url = hrefTorrent($torrent);
if ($torrent->doubleup == 0) {
$torrent->doubleup = "1";
// Announce To Chat
Message::create(['user_id' => "1", 'chatroom_id' => "3", 'message' => "Ladies and Gents, [url={$appurl}/torrents/{$torrent->slug}.{$torrent->id}]{$torrent->name}[/url] has been granted Double Upload! Grab It While You Can! :fire:"]);
$this->chat->systemMessage(
"Ladies and Gents, [url={$torrent_url}]{$torrent->name}[/url] has been granted Double Upload! Grab It While You Can! :fire:"
);
} else {
$torrent->doubleup = "0";
// Announce To Chat
Message::create(['user_id' => "1", 'chatroom_id' => "3", 'message' => "Ladies and Gents, [url={$appurl}/torrents/{$torrent->slug}.{$torrent->id}]{$torrent->name}[/url] has been revoked of its Double Upload! :poop:"]);
$this->chat->systemMessage(
"Ladies and Gents, [url={$torrent_url}]{$torrent->name}[/url] has been revoked of its Double Upload! :poop:"
);
}
$torrent->save();
// Activity Log
\LogActivity::addToLog("Staff Member " . auth()->user()->username . " has granted double upload on torrent, ID: {$torrent->id} NAME: {$torrent->name} .");
\LogActivity::addToLog("Staff Member " . $user->username . " has granted double upload on torrent, ID: {$torrent->id} NAME: {$torrent->name} .");
return redirect()->route('torrent', ['slug' => $torrent->slug, 'id' => $torrent->id])->with(Toastr::success('Torrent DoubleUpload Has Been Adjusted!', 'Yay!', ['options']));
} else {
@@ -842,8 +865,12 @@ class TorrentController extends Controller
$pmuser->save();
}
// Announce To Chat
Message::create(['user_id' => "1", 'chatroom_id' => "3", 'message' => "Ladies and Gents, [url={$appurl}/{$user->username}.{$user->id}]{$user->username}[/url] has requested a reseed on [url={$appurl}/torrents/{$torrent->slug}.{$torrent->id}]{$torrent->name}[/url] can you help out :question:"]);
$torrent_url = hrefTorrent($torrent);
$profile_url = hrefProfile($user);
$this->chat->systemMessage(
"Ladies and Gents, [url={$profile_url}[/url] has requested a reseed on [url={$torrent_url}[/url] can you help out :question:"
);
// Activity Log
\LogActivity::addToLog("Member {$user->username} has requested a reseed request on torrent, ID: {$torrent->id} NAME: {$torrent->name} .");
+10 -9
View File
@@ -12,20 +12,18 @@
namespace App\Listeners;
use App\Repositories\ChatRepository;
use Gstt\Achievements\Event\Unlocked;
use App\Message;
use App\User;
class AchievementUnlocked
{
/**
* Create the event listener.
*
* @return void
*/
public function __construct()
private $chat;
public function __construct(ChatRepository $chat)
{
//
$this->chat = $chat;
}
/**
@@ -41,8 +39,11 @@ class AchievementUnlocked
session()->flash('achievement', $event->progress->details->name);
if ($user->private_profile == 0) {
$appurl = config('app.url');
Message::create(['user' => "1", 'chatroom_id' => "3", 'message' => "User [url={$appurl}/" . $user->username . "." . $user->id . "]" . $user->username . "[/url] has unlocked the " . $event->progress->details->name . " achievement :medal:"]);
$profile_url = hrefProfile($user);
$this->chat->systemMessage(
"User [url={$profile_url}]{$user->username}[/url] has unlocked the {$event->progress->details->name} achievement :medal:"
);
}
}
}