Skip to content

Commit

Permalink
whatever i changed
Browse files Browse the repository at this point in the history
  • Loading branch information
jcrutchy committed May 18, 2016
1 parent c353665 commit 9221b88
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 30 deletions.
38 changes: 19 additions & 19 deletions exec_freenode.txt
Expand Up @@ -4,38 +4,38 @@
include ./scripts/quit.php
include ./scripts/part.php
include ./scripts/join.php
include ./scripts/admin.php
include ./scripts/help.php
include ./scripts/privmsg.php
include ./scripts/seen.php
include ./scripts/tell.php
#include ./scripts/admin.php
#include ./scripts/help.php
#include ./scripts/privmsg.php
#include ./scripts/seen.php
#include ./scripts/tell.php
include ./scripts/sed.php
include ./scripts/title.php
include ./scripts/welcome.php
include ./scripts/karma.php
include ./scripts/convert.php
include ./scripts/definitions.php
include ./scripts/link.php
include ./scripts/google.php
#include ./scripts/welcome.php
#include ./scripts/karma.php
#include ./scripts/convert.php
#include ./scripts/definitions.php
#include ./scripts/link.php
#include ./scripts/google.php
include ./scripts/time.php
include ./scripts/weather.php
include ./scripts/location.php
include ./scripts/translate.php
include ./scripts/japanese.php
include ./scripts/jisho2.php
include ./scripts/users.php
#include ./scripts/users.php

include ./scripts/rps.php

help ./scripts
#help ./scripts

init ./scripts

~calc|5|0|1|1|||||/usr/bin/units -t %%trailing%%
help ~calc|syntax: ~calc <expression>
help ~calc|evaluates math expression
#~calc|5|0|1|1|||||/usr/bin/units -t %%trailing%%
#help ~calc|syntax: ~calc <expression>
#help ~calc|evaluates math expression

include ./scripts/ruby/currency.rb
#include ./scripts/ruby/currency.rb

include ./scripts/sneak/sneak_server.php
startup ./scripts/sneak/sneak_server.php
#include ./scripts/sneak/sneak_server.php
#startup ./scripts/sneak/sneak_server.php
13 changes: 7 additions & 6 deletions scripts/sneak/data_client.php
Expand Up @@ -39,12 +39,13 @@
}
stream_set_blocking($socket,0);

$unpacked=array();
$unpacked["dest"]=$dest;
$unpacked["nick"]=$nick;
$unpacked["user"]=$user;
$unpacked["hostname"]=$hostname;
$unpacked["trailing"]=$trailing;
$unpacked=array(
"dest"=>$dest,
"nick"=>$nick,
"user"=>$user,
"hostname"=>$hostname,
"trailing"=>$trailing);

$data=base64_encode(serialize($unpacked));
fputs($socket,$data."\n");
$t=microtime(True);
Expand Down
46 changes: 45 additions & 1 deletion scripts/sneak/data_server.php
Expand Up @@ -140,6 +140,38 @@ function server_msg_handler(&$server_data,&$server,&$clients,&$connections,$clie
unset_bucket(SERVER_BUCKET_INDEX);
}
break;
case "test":
if (count($parts)==0)
{
privmsg("error: missing test mod action");
}
privmsg("test mode");
define("TEST_MODE","1");
$action=array_shift($parts);
$server_data=array(
"irc_server"=>$server,
"listen_port"=>50000,
"dest"=>$dest,
"app_data_updated"=>False,
"app_data"=>array(),
"server_admin"=>$hostname);
$server=Null;
$clients=array();
$connections=array();
$unpacked=array(
"dest"=>$dest,
"nick"=>$nick,
"user"=>"",
"hostname"=>$hostname,
"trailing"=>implode(" ",$parts));
$response=array();
$response["msg"]=array();
load_mod($server_data,$server,$clients,$connections,0,$unpacked,$response,$parts,$action);
for ($i=0;$i<count($response["msg"]);$i++)
{
privmsg($response["msg"][$i]);
}
return;
default:
privmsg("syntax: $alias status|start|stop");
break;
Expand Down Expand Up @@ -493,6 +525,11 @@ function on_msg(&$server_data,&$server,&$clients,&$connections,$client_index,$da

function server_reply(&$server_data,&$server,&$clients,&$connections,$client_index,$msg)
{
if (defined("TEST_MODE")==True)
{
privmsg("test mode: ".$msg);
return;
}
$response=array();
$response["msg"][]=$msg;
$data=base64_encode(serialize($response));
Expand Down Expand Up @@ -525,6 +562,11 @@ function load_mod(&$server_data,&$server,&$clients,&$connections,$client_index,$
{
return False;
}
if (defined("TEST_MODE")==True)
{
# save $code to temp file, include it, then unlink temp file
return;
}
$result=@eval($code);
if ($result===False)
{
Expand All @@ -541,7 +583,7 @@ function read_mod(&$server_data,&$server,&$clients,&$connections,$client_index,$
if (file_exists($mod_filename)==False)
{
server_reply($server_data,$server,$clients,$connections,$client_index,"mod: file \"".$filename."\" not found");
return False;
return;
}
$code=file_get_contents($mod_filename);
if ($code===False)
Expand Down Expand Up @@ -591,6 +633,8 @@ function read_mod(&$server_data,&$server,&$clients,&$connections,$client_index,$
server_reply($server_data,$server,$clients,$connections,$client_index,"mod: include macro read error");
continue;
}
$include_lines=explode(PHP_EOL,$include_code);
$lines=array_merge($include_lines,$lines);
break;
default:
server_reply($server_data,$server,$clients,$connections,$client_index,"mod: invalid macro operation");
Expand Down
8 changes: 4 additions & 4 deletions scripts/sneak/mods/mod_sneak_test
Expand Up @@ -2,6 +2,10 @@

#####################################################################################################

/*
mod:include lib_sneak
*/

/*
AVAILABLE VARIABLES:
&$server_data
Expand All @@ -15,10 +19,6 @@ $trailing_parts
$action
*/

# TODO: SEE IF YOU CAN GET A SIMPLE PHP INCLUDE TO WORK INSTEAD OF USING A MOD INCLUDE MACRO
# TODO: MAYBE TRY TO FIGURE OUT A WAY TO TEST MODS IN A KIND OF SANDBOX SO THAT ANY ERRORS DON'T BRICK THE MAIN SERVER
include(__FILE__."/mods/lib_sneak");

if (is_gm($server_data,$unpacked["hostname"])==True)
{
$response["msg"][]="my butt smells";
Expand Down

0 comments on commit 9221b88

Please sign in to comment.