Skip to content

Commit c8a9966

Browse files
Initial commit.
1 parent 47f56b7 commit c8a9966

File tree

126 files changed

+40724
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

126 files changed

+40724
-0
lines changed

.editorconfig

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
indent_size = 4
7+
indent_style = space
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false
13+
14+
[*.{yml,yaml}]
15+
indent_size = 2
16+
17+
[docker-compose.yml]
18+
indent_size = 4

.env.example

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
APP_NAME=Laravel
2+
APP_ENV=local
3+
APP_KEY=
4+
APP_DEBUG=true
5+
APP_URL=http://localhost
6+
7+
LOG_CHANNEL=stack
8+
LOG_DEPRECATIONS_CHANNEL=null
9+
LOG_LEVEL=debug
10+
11+
DB_CONNECTION=mysql
12+
DB_HOST=127.0.0.1
13+
DB_PORT=3306
14+
DB_DATABASE=laravel
15+
DB_USERNAME=root
16+
DB_PASSWORD=
17+
18+
BROADCAST_DRIVER=log
19+
CACHE_DRIVER=file
20+
FILESYSTEM_DISK=local
21+
QUEUE_CONNECTION=sync
22+
SESSION_DRIVER=file
23+
SESSION_LIFETIME=120
24+
25+
MEMCACHED_HOST=127.0.0.1
26+
27+
REDIS_HOST=127.0.0.1
28+
REDIS_PASSWORD=null
29+
REDIS_PORT=6379
30+
31+
MAIL_MAILER=smtp
32+
MAIL_HOST=mailhog
33+
MAIL_PORT=1025
34+
MAIL_USERNAME=null
35+
MAIL_PASSWORD=null
36+
MAIL_ENCRYPTION=null
37+
MAIL_FROM_ADDRESS="[email protected]"
38+
MAIL_FROM_NAME="${APP_NAME}"
39+
40+
AWS_ACCESS_KEY_ID=
41+
AWS_SECRET_ACCESS_KEY=
42+
AWS_DEFAULT_REGION=us-east-1
43+
AWS_BUCKET=
44+
AWS_USE_PATH_STYLE_ENDPOINT=false
45+
46+
PUSHER_APP_ID=
47+
PUSHER_APP_KEY=
48+
PUSHER_APP_SECRET=
49+
PUSHER_HOST=
50+
PUSHER_PORT=443
51+
PUSHER_SCHEME=https
52+
PUSHER_APP_CLUSTER=mt1
53+
54+
VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
55+
VITE_PUSHER_HOST="${PUSHER_HOST}"
56+
VITE_PUSHER_PORT="${PUSHER_PORT}"
57+
VITE_PUSHER_SCHEME="${PUSHER_SCHEME}"
58+
VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

.gitattributes

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
* text=auto
2+
3+
*.blade.php diff=html
4+
*.css diff=css
5+
*.html diff=html
6+
*.md diff=markdown
7+
*.php diff=php
8+
9+
/.github export-ignore
10+
CHANGELOG.md export-ignore
11+
.styleci.yml export-ignore

.gitignore

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/node_modules
2+
/public/build
3+
/public/hot
4+
/public/storage
5+
/storage/*.key
6+
/vendor
7+
.env
8+
.env.backup
9+
.env.production
10+
.phpunit.result.cache
11+
Homestead.json
12+
Homestead.yaml
13+
auth.json
14+
npm-debug.log
15+
yarn-error.log
16+
/.fleet
17+
/.idea
18+
/.vscode
+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
<?php
2+
3+
namespace App\Console\Commands;
4+
5+
use Illuminate\Console\Command;
6+
use \CodeWizz\RedditAPI\RedditAPI;
7+
use App\Notifications\NewJobMessage;
8+
use Notification;
9+
use App\User;
10+
use App\Message;
11+
12+
class checkRedditMsg extends Command
13+
{
14+
/**
15+
* The name and signature of the console command.
16+
*
17+
* @var string
18+
*/
19+
protected $signature = 'command:checkRedditMsg';
20+
21+
/**
22+
* The console command description.
23+
*
24+
* @var string
25+
*/
26+
protected $description = 'Check Reddit for new messages and send notifications.';
27+
28+
/**
29+
* Create a new command instance.
30+
*
31+
* @return void
32+
*/
33+
public function __construct()
34+
{
35+
parent::__construct();
36+
}
37+
38+
/**
39+
* Execute the console command.
40+
*
41+
* @return mixed
42+
*/
43+
public function handle()
44+
{
45+
$reddit = new RedditAPI("taodev91", "8fJUWB3exETiW78", "z6U6lida0GFEzacynDcllw", "a_7heyaSC04o9HoYK_5gTweI30tYmg", "https://www.reddit.com", "https://oauth.reddit.com", "STD");
46+
$messages = $reddit->getUnread();
47+
48+
print_r($messages);
49+
/* If new messages then send out web push notification for phone alert */
50+
if(count($messages->data->children)) {
51+
foreach($messages->data->children as $message) {
52+
$msg = $message->data;
53+
print_r($msg);
54+
$exists = Message::where("reddit_id", "=", $msg->id)->first();
55+
if(!$exists) {
56+
57+
/* Insert Link into Database */
58+
$message = new Message;
59+
$message->reddit_id = $msg->id;
60+
$message->body_html = $msg->body_html;
61+
$message->body = $msg->body;
62+
$message->author = $msg->author;
63+
$message->save();
64+
65+
$cmd = "ASLkjda*s@ !yQgCRtXrhmRNbyRMiV:subtlefu.ge <b>Reddit Message from: ".$msg->author." (https://www.reddit.com/message/messages/".$msg->id.")</b><br><table width='100%' border='0'><tr><td><img width='25' height='25' src='https://subtlefu.ge/_matrix/media/r0/download/subtlefu.ge/pxhTywhmnTENTwwXxNKXEAPs'></td><td><pre>".$msg->body."</pre></td></tr></table>";
66+
$fp = fsockopen("tcp://subtlefu.ge", 1337, $errno, $errstr, 30);
67+
if(!$cmd) return "no command given...";
68+
if(!$fp) return "conn. refused";
69+
70+
$response = "";
71+
fwrite($fp, $cmd);
72+
//while (!feof($fp)) {
73+
// $response .= fgets($fp, 128);
74+
//}
75+
fclose($fp);
76+
77+
/* Send out notifications for web browser / android */
78+
Notification::send(User::all(),new NewJobMessage([
79+
"title"=>"New Reddit Message!",
80+
"body" => "Check Reddit for message.",
81+
"icon" => "https://codebuilder.us/images/mandala4_75.png"
82+
]));
83+
}
84+
85+
}
86+
87+
88+
}
89+
90+
}
91+
}

app/Console/Commands/runIRCBot.php

+134
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
<?php
2+
3+
namespace App\Console\Commands;
4+
5+
use Illuminate\Console\Command;
6+
use Phergie\Irc\Connection;
7+
use BitcoinVietnam\BitcoinAverage;
8+
use Illuminate\Support\Facades\Redis;
9+
10+
class runIRCBot extends Command
11+
{
12+
/**
13+
* The name and signature of the console command.
14+
*
15+
* @var string
16+
*/
17+
protected $signature = 'command:runIRCBot';
18+
19+
/**
20+
* The console command description.
21+
*
22+
* @var string
23+
*/
24+
protected $description = 'Command to start phappr IRC bot.';
25+
26+
/**
27+
* Create a new command instance.
28+
*
29+
* @return void
30+
*/
31+
public function __construct()
32+
{
33+
parent::__construct();
34+
}
35+
36+
public function connection() {
37+
return $this->connection = new Connection(array(
38+
// Required settings
39+
'serverHostname' => 'codebuilder.org',
40+
'username' => 'Phappr',
41+
'realname' => 'Tyler Durden',
42+
'nickname' => 'Phappr',
43+
// Optional settings
44+
'hostname' => '[email protected]',
45+
'serverport' => 6667,
46+
// 'password' => 'password goes here if needed',
47+
//'options' => array(
48+
// 'transport' => 'ssl',
49+
//'force-ipv4' => true,
50+
//)
51+
));
52+
}
53+
54+
public function config() {
55+
56+
$this->connection();
57+
$config = array(
58+
// Plugins to include for all connections
59+
'plugins' => array(
60+
// new \Vendor\Plugin\PluginName(array(
61+
// /* configuration goes here */
62+
// )),
63+
),
64+
'connections' => array($this->connection)
65+
);
66+
return $config;
67+
}
68+
69+
/**
70+
* Execute the console command.
71+
*
72+
* @return mixed
73+
*/
74+
public function handle()
75+
{
76+
77+
$config = $this->config();
78+
$connection = $this->connection;
79+
$bot = new \Phergie\Irc\Bot\React\Bot;
80+
$bot->setConfig($config);
81+
82+
/* Begin client logic for bot handling of events */
83+
$client = new \Phergie\Irc\Client\React\Client();
84+
$client->on('irc.received', function($message, $write, $connection, $logger) {
85+
if ($message['command'] == 'DEBUG') return false;
86+
if ($message['command'] == 'NOTICE') return false;
87+
$GLOBALS["write"] = $write;
88+
$write->ircJoin("#root");
89+
90+
//die(print_r($message));
91+
//$write->ircPrivmsg($message["params"]["receivers"], " USD");
92+
93+
94+
if ($message['command'] == 'PRIVMSG') {
95+
if(strstr("!b", $message["params"]["text"])) {
96+
$usd = $this->convertUSD();
97+
$write->ircPrivmsg($message["params"]["receivers"], '$'.$usd." USD");
98+
}
99+
$nick = $message['nick'];
100+
}
101+
//$channel = $message['params']['channels'];
102+
//$nick = $message['nick'];
103+
//$write->ircPrivmsg($channel, 'Welcome ' . $nick . '!');
104+
});
105+
106+
107+
/* Periodic timer to check redis for new messages that bot should echo / relay */
108+
$client->addPeriodicTimer(5, function() {
109+
echo "hi bitch \n\n\n";
110+
global $write;
111+
112+
$queue = Redis::get("TcpIRCQue");
113+
$queue = json_decode(($queue));
114+
if(is_array($queue)) {
115+
foreach($queue as $message) $write->ircPrivmsg("#root", $message);
116+
}
117+
//reset message queue to null after sending them all
118+
Redis::set('TcpIRCQue', null);
119+
});
120+
121+
$client->run($connection);
122+
123+
/* Start up the bot */
124+
$bot->run();
125+
126+
127+
}
128+
129+
public function convertUSD() {
130+
$client = new BitcoinAverage\Client($apiKey = "YjgwZmJmNmEwMTc0NDllY2FiY2ZlZmZkMjNiYTNhMzA", $apiSecret = "NmQ2MTI3MmM3MTIzNDZlOTlmZjA2YTFlZGRhZDRlM2ExYWRkNDJjZGQzN2E0NDEwODc0ZjQ4YjJmNWU3OTBhMg");
131+
$conversion = $client->getTickerPerSymbol("BTCUSD", "global");
132+
return $conversion->getLast();
133+
}
134+
}

0 commit comments

Comments
 (0)