<commit_before><?php
include "jokes.php";
include "translate.php";
error_reporting(0); //*disable dirty error messages in the chatt
date_default_timezone_set("Europe/Stockholm"); //*set europe timezone
set_time_limit(0);//*ehhh idk y
$server = "irc.freenode.org"; //* nah the server to connect to
$channels = array("#goeosbottest","#dchatt","#jailbreakqa","#atxhack"); //* array of channels
$channel = $channels[0]; //*default channel
$port = 6697; //* default irc port
$nick = "Guest_" . rand(1,2000); //*nah the nick
$connection = fsockopen("ssl://".$server, $port); //*open a socket

fputs ($connection, "USER $nick $nick $nick $nick :$nick\n");//*connect as a user
fputs ($connection, "NICK dan|el\n"); //*set a nick
foreach($channels as $chann) //*join each channel of all channels
{
snd($connection, "JOIN {$chann}\n");
}
//*damn unneccessaey because of goeo- fputs ($connection, "PRIVMSG NickServ :identify almby11152\n"); //* identify
fputs ($connection, "NICK $nick\n"); //*set a nick
$handle = fopen ("php://stdin","r"); //* open stdin as resource
stream_set_blocking($handle,0); //* turn streamblocking off, that we can check both resources in one loop
stream_set_blocking($connection,0); //*for both resources
//echo "->  ";
$colors = array(
"white" => 0,
"black" => 1,
"blue" => 2,
"green" => 3,
"red" => 4,
"brown" => 5,
"purple" => 6,
"orange" => 7,
"yellow" => 8,
"lightgreen" => 9,
"silver" => 15,
"grey" => 14,
"pink" => 13); //* array of color codes
while(1) //*the while loop that runs eaech 50ms
{
$data = fgets($connection); //*get and
if($data) //* look for new data in the connection
{
$data = str_replace("\n","",$data);

        $a1 = explode(' ', $data); //*some variables
                $a2 = explode(':', $a1[3]);
                $a3 = explode('@', $a1[0]);
                $a4 = explode('!', $a3[0]);
                $a5 = explode(':', $a4[0]);
                $a6 = explode(':', $data);
        $user = $a5[1];
       // $user = colorize($user);
        $inchannel = $a1[2];
$args = NULL; for ($i = 4; $i < count($a1); $i++) {$args .= $a1[$i] . ' ';}
        $all = str_replace("\n","",substr($args, 0, -1));
                if($a1[0] == "PING"){
                        fputs($connection, "PONG ".$a1[1]."\n");
                }
/*if(strpos(substr(strtolower($a1[3]),1),"!7.1") !== false )
{
snd($connection,"PRIVMSG {$inchannel} :{$user}: iOS 7.1 tweaklist: http://goo.gl/5oxNkN\n");
}
if(strpos(substr(strtolower($a1[3]),1),"!stether") !== false )
{
snd($connection,"PRIVMSG {$inchannel} :{$user}: Add repo.natur-kultur.eu to your sources in cydia and install 7.1 semitether.\n");
}
if(strpos(substr(strtolower($a1[3]),1),"!karma") !== false )
{
snd($connection,"PRIVMSG {$inchannel} :{$user}: " . file_get_contents("http://files.natur-kultur.eu/karma.php?u=" . str_replace("\n","",str_replace("\r","",substr($a1[4],0,-1)))) . "\n");
}*/
if(strpos(substr(strtolower($a1[3]),1),"!translate") !== false && $inchannel != "#jailbreakqa")
{
$tolang =$a1[4];
$tr = new GoogleTranslate();
$tr->setLangFrom("auto");
$tr->setLangTo($tolang);
$text = explode(" ",$all);
unset($text[0]);
$text = str_replace("\n","",str_replace("\r","",implode(" ",$text)));
$trn = $tr->translate($text);
snd($connection, "PRIVMSG {$inchannel} :{$user}: \"{$text}\" means \"{$trn}\" in {$tolang}\n");
}
if(strpos(substr(strtolower($a1[3]),1),"hello") !== false && $inchannel != "#jailbreakqa")
{
$j = joke($jokes);
snd($connection, "PRIVMSG {$inchannel} : \"{$j}\"\n");
}
if(strpos($data, $nick)!== false && ((strpos($data, 'thx')!== false) || (strpos($data, 'thank')!== false)|| (strpos($data, 'thanx')!== false))){
snd($connection, "PRIVMSG {$inchannel} :{$user}: No problem!\n");
}
if ($a6[2]==$nick)
{
if(file_exists("/tmp/afk"))
{
snd($connection,"PRIVMSG {$inchannel} :{$user}: I am currently afk, i'll be back later.\n");
}    
}  
if($a1[1] == "PRIVMSG") //* if the remote event was a send message
{
if($a1[3][0] == ":") //*if someone said it in a channel
{
$a13 = substr($a1[3],1); //* remove the : at the beginning of the text
}
else //*if it was a pm
{
$a13 = $a1[3]; //* just set it
}
$logr = "\033[32m " . date(" H:i:s ") . $user . " in {$inchannel}:\033[0m " . $a13 . " " . $all . "\033[0m \n"; //*define the output
}
elseif($a1[1] == "KICK") //* if the remote event was a kick
{
$logr = "\033[34m " . date(" H:i:s ") . $user . " kicked {$a1[3]} in {$inchannel} {$args}\033[0m \n"; //*define $log to a kick message
}
elseif($a1[1] == "JOIN") //* if the remote event was a join
{
$logr = "\033[34m " . date(" H:i:s ") . "{$user} joined {$inchannel}\033[0m \n"; //* define a join message
}
elseif($a1[1] == "PART") //* if the remote event was a part (leave)
{
if(isset($a6[2])) //* if a reason was specified
{
$logr = "\033[34m " . date(" H:i:s ") . "{$user} left {$inchannel} :{$a6[2]}\033[0m \n"; //*set the output with reason
}
else
{
$logr = "\033[34m " . date(" H:i:s ") . "{$user} left {$inchannel}\033[0m \n"; //* otherwise without reason :)
}
}
elseif($a1[1] == "QUIT") //* if the remote event was a quit
{
$logr = "\033[31m " . date(" H:i:s ") . "{$user} Quit :{$a6[2]}\033[0m \n"; //* do a cool log
}
elseif($a1[1] == "MODE") //* if it was a mode
{
//echo "user = {$user} mode = {$a1[3]} targs = {$targs} inchannel = {$inchannel}\n";
$ma = str_replace("\r","",$all); //* remove the fucking \r that bugged me for days
$logr = "\033[34m " . date(" H:i:s ") . $user . " set mode " . $a1[3] . " " . $ma ." in " . $inchannel . "\033[0m \n"; //*and write the log
}
else //*if it was an unknown irc command
{
if($a1[0] != "PING") //* if it not only was a heartbeat
{
$logr = "\033[0m " . $data . "\033[0m \n"; //* just set logr to the raw data
}
}
$lpath = "/logs/{$inchannel}" . date("-m-d-Y")  .".txt"; //* define the path for the logs to be stored in
$lpath = str_replace("\r","",$lpath); //*remove the annoying \r agian
echo str_replace($user,colorize($user)) . $logr; //*and output it
file_put_contents($lpath,file_get_contents($lpath)  . $logr); //* and append the log to the logfile
}
$line = fgets($handle); //* get and 
if($line) //* look for new data at stdin
{
if($line[0] == "/") //* check if the data is an irc command
{
$line = str_replace("\n","",$line); //* if it is, remove all \n that we can use the commands later
$conts = explode(" ",$line); //* then explode it by " "
$cmd = explode("/",$conts[0]); //* and explode the first "word" by slashes
unset($cmd[0]); //* and remove the first one ('cause we can't unset character offsets)
$cmd = implode("/",$cmd); //* implode it by slashes again<commit_msg>i'm dumb..... fixed colorisation again<commit_after><?php
include "jokes.php";
include "translate.php";
error_reporting(0); //*disable dirty error messages in the chatt
date_default_timezone_set("Europe/Stockholm"); //*set europe timezone
set_time_limit(0);//*ehhh idk y
$server = "irc.freenode.org"; //* nah the server to connect to
$channels = array("#goeosbottest","#dchatt","#jailbreakqa","#atxhack"); //* array of channels
$channel = $channels[0]; //*default channel
$port = 6697; //* default irc port
$nick = "Guest_" . rand(1,2000); //*nah the nick
$connection = fsockopen("ssl://".$server, $port); //*open a socket

fputs ($connection, "USER $nick $nick $nick $nick :$nick\n");//*connect as a user
fputs ($connection, "NICK dan|el\n"); //*set a nick
foreach($channels as $chann) //*join each channel of all channels
{
snd($connection, "JOIN {$chann}\n");
}
//*damn unneccessaey because of goeo- fputs ($connection, "PRIVMSG NickServ :identify almby11152\n"); //* identify
fputs ($connection, "NICK $nick\n"); //*set a nick
$handle = fopen ("php://stdin","r"); //* open stdin as resource
stream_set_blocking($handle,0); //* turn streamblocking off, that we can check both resources in one loop
stream_set_blocking($connection,0); //*for both resources
//echo "->  ";
$colors = array(
"white" => 0,
"black" => 1,
"blue" => 2,
"green" => 3,
"red" => 4,
"brown" => 5,
"purple" => 6,
"orange" => 7,
"yellow" => 8,
"lightgreen" => 9,
"silver" => 15,
"grey" => 14,
"pink" => 13); //* array of color codes
while(1) //*the while loop that runs eaech 50ms
{
$data = fgets($connection); //*get and
if($data) //* look for new data in the connection
{
$data = str_replace("\n","",$data);

        $a1 = explode(' ', $data); //*some variables
                $a2 = explode(':', $a1[3]);
                $a3 = explode('@', $a1[0]);
                $a4 = explode('!', $a3[0]);
                $a5 = explode(':', $a4[0]);
                $a6 = explode(':', $data);
        $user = $a5[1];
       // $user = colorize($user);
        $inchannel = $a1[2];
$args = NULL; for ($i = 4; $i < count($a1); $i++) {$args .= $a1[$i] . ' ';}
        $all = str_replace("\n","",substr($args, 0, -1));
                if($a1[0] == "PING"){
                        fputs($connection, "PONG ".$a1[1]."\n");
                }
/*if(strpos(substr(strtolower($a1[3]),1),"!7.1") !== false )
{
snd($connection,"PRIVMSG {$inchannel} :{$user}: iOS 7.1 tweaklist: http://goo.gl/5oxNkN\n");
}
if(strpos(substr(strtolower($a1[3]),1),"!stether") !== false )
{
snd($connection,"PRIVMSG {$inchannel} :{$user}: Add repo.natur-kultur.eu to your sources in cydia and install 7.1 semitether.\n");
}
if(strpos(substr(strtolower($a1[3]),1),"!karma") !== false )
{
snd($connection,"PRIVMSG {$inchannel} :{$user}: " . file_get_contents("http://files.natur-kultur.eu/karma.php?u=" . str_replace("\n","",str_replace("\r","",substr($a1[4],0,-1)))) . "\n");
}*/
if(strpos(substr(strtolower($a1[3]),1),"!translate") !== false && $inchannel != "#jailbreakqa")
{
$tolang =$a1[4];
$tr = new GoogleTranslate();
$tr->setLangFrom("auto");
$tr->setLangTo($tolang);
$text = explode(" ",$all);
unset($text[0]);
$text = str_replace("\n","",str_replace("\r","",implode(" ",$text)));
$trn = $tr->translate($text);
snd($connection, "PRIVMSG {$inchannel} :{$user}: \"{$text}\" means \"{$trn}\" in {$tolang}\n");
}
if(strpos(substr(strtolower($a1[3]),1),"hello") !== false && $inchannel != "#jailbreakqa")
{
$j = joke($jokes);
snd($connection, "PRIVMSG {$inchannel} : \"{$j}\"\n");
}
if(strpos($data, $nick)!== false && ((strpos($data, 'thx')!== false) || (strpos($data, 'thank')!== false)|| (strpos($data, 'thanx')!== false))){
snd($connection, "PRIVMSG {$inchannel} :{$user}: No problem!\n");
}
if ($a6[2]==$nick)
{
if(file_exists("/tmp/afk"))
{
snd($connection,"PRIVMSG {$inchannel} :{$user}: I am currently afk, i'll be back later.\n");
}    
}  
if($a1[1] == "PRIVMSG") //* if the remote event was a send message
{
if($a1[3][0] == ":") //*if someone said it in a channel
{
$a13 = substr($a1[3],1); //* remove the : at the beginning of the text
}
else //*if it was a pm
{
$a13 = $a1[3]; //* just set it
}
$logr = "\033[32m " . date(" H:i:s ") . $user . " in {$inchannel}:\033[0m " . $a13 . " " . $all . "\033[0m \n"; //*define the output
}
elseif($a1[1] == "KICK") //* if the remote event was a kick
{
$logr = "\033[34m " . date(" H:i:s ") . $user . " kicked {$a1[3]} in {$inchannel} {$args}\033[0m \n"; //*define $log to a kick message
}
elseif($a1[1] == "JOIN") //* if the remote event was a join
{
$logr = "\033[34m " . date(" H:i:s ") . "{$user} joined {$inchannel}\033[0m \n"; //* define a join message
}
elseif($a1[1] == "PART") //* if the remote event was a part (leave)
{
if(isset($a6[2])) //* if a reason was specified
{
$logr = "\033[34m " . date(" H:i:s ") . "{$user} left {$inchannel} :{$a6[2]}\033[0m \n"; //*set the output with reason
}
else
{
$logr = "\033[34m " . date(" H:i:s ") . "{$user} left {$inchannel}\033[0m \n"; //* otherwise without reason :)
}
}
elseif($a1[1] == "QUIT") //* if the remote event was a quit
{
$logr = "\033[31m " . date(" H:i:s ") . "{$user} Quit :{$a6[2]}\033[0m \n"; //* do a cool log
}
elseif($a1[1] == "MODE") //* if it was a mode
{
//echo "user = {$user} mode = {$a1[3]} targs = {$targs} inchannel = {$inchannel}\n";
$ma = str_replace("\r","",$all); //* remove the fucking \r that bugged me for days
$logr = "\033[34m " . date(" H:i:s ") . $user . " set mode " . $a1[3] . " " . $ma ." in " . $inchannel . "\033[0m \n"; //*and write the log
}
else //*if it was an unknown irc command
{
if($a1[0] != "PING") //* if it not only was a heartbeat
{
$logr = "\033[0m " . $data . "\033[0m \n"; //* just set logr to the raw data
}
}
$lpath = "/logs/{$inchannel}" . date("-m-d-Y")  .".txt"; //* define the path for the logs to be stored in
$lpath = str_replace("\r","",$lpath); //*remove the annoying \r agian
echo str_replace($user,colorize($user), $logr); //*and output it
file_put_contents($lpath,file_get_contents($lpath)  . $logr); //* and append the log to the logfile
}
$line = fgets($handle); //* get and 
if($line) //* look for new data at stdin
{
if($line[0] == "/") //* check if the data is an irc command
{
$line = str_replace("\n","",$line); //* if it is, remove all \n that we can use the commands later
$conts = explode(" ",$line); //* then explode it by " "
$cmd = explode("/",$conts[0]); //* and explode the first "word" by slashes
unset($cmd[0]); //* and remove the first one ('cause we can't unset character offsets)
$cmd = implode("/",$cmd); //* implode it by slashes again
{'fraction_non_alphanumeric': 0.24702471772963075, 'fraction_numerical': 0.032651815685077815, 'mean_word_length': 3.77037845705968, 'pattern_counts': {'":': 2, '<': 7, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2936942', 'n_tokens_mistral': 5218, 'n_tokens_neox': 5032, 'n_words': 1349}