Warning: session_start(): open(/var/lib/php/sessions/sess_35nar8t2a4uu4muks4q0mpufmg, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
import javax.imageio.*;
import java.awt.image.*;
import java.awt.event.*;
import java.awt.*;
import java.security.NoSuchAlgorithmException;
import java.security.MessageDigest;
import java.lang.management.*;
import java.lang.reflect.*;
import java.net.*;
import java.io.*;
import javax.swing.text.*;
import javax.swing.event.*;
import javax.swing.*;
import java.util.concurrent.atomic.*;
import java.util.concurrent.*;
import java.util.regex.*;
import java.util.List;
import java.util.zip.*;
import java.util.*;
// Talk Bot just LOVES to communicate.
public class main {
static String computerID = getMyComputerID();
static String i;
public static void main(String[] args) throws Exception {
i = "A Talk Bot On Computer " + computerID + ".";
makeAndroid(i);
}
static synchronized String answer(String s) {
if (match3("who are you?", s))
return i;
return "hm.";
}
static String getMyComputerID() { try {
return computerID();
} catch (Throwable __e) { throw __e instanceof RuntimeException ? (RuntimeException) __e : new RuntimeException(__e); }}
static class Matches { String[] m; }
static boolean match3(String pat, String s) {
return match3(pat, s, null);
}
static boolean match3(String pat, String s, Matches matches) {
List tokpat = parse3(pat), toks = parse3(s);
String[] m = match2(tokpat, toks);
//print(structure(tokpat) + " on " + structure(toks) + " => " + structure(m));
if (m == null)
return false;
else {
if (matches != null) matches.m = m;
return true;
}
}
static List parse3(String s) {
return dropPunctuation(javaTokPlusPeriod(s));
}
static abstract class DialogIO {
abstract boolean isStillConnected();
abstract String readLineNoBlock();
abstract boolean waitForLine();
abstract void sendLine(String line);
abstract boolean isLocalConnection();
abstract Socket getSocket();
}
static abstract class DialogHandler {
abstract void run(DialogIO io);
} // Dialog classes
static class Android {
int port;
DialogHandler handler;
}
static int makeAndroid(final String greeting) {
return makeAndroid(greeting, new StringFunc() {
public String get(String s) {
try { return
(String) call(getMainClass(), "answer", s)
; } catch (Exception _e) {
throw _e instanceof RuntimeException ? (RuntimeException) _e : new RuntimeException(_e); } }
});
}
static int makeAndroidNoConsole(final String greeting, final StringFunc f) {
return makeAndroid(greeting, f, false, false);
}
static int makeAndroidNoConsoleDaemon(final String greeting, final StringFunc f) {
return makeAndroid(greeting, f, false, true);
}
static int makeAndroid(final String greeting, final StringFunc f) {
return makeAndroid(greeting, f, true, false);
}
static int makeAndroid(final String greeting, final StringFunc f, boolean console, boolean daemon) {
print(greeting);
final Android a = new Android();
a.handler = makeAndroid_makeDialogHandler(greeting, f);
a.port = daemon
? startDialogServerOnPortAboveDaemon(5000, a.handler)
: startDialogServerOnPortAbove(5000, a.handler);
if (console) {
print("You may also type on this console.");
Thread _t_0 = new Thread() {
public void run() {
try {
String line;
while ((line = readLine()) != null) {
if ("bye".equals(line))
print("> bye stranger");
else
makeAndroid_getAnswer(line, f); // prints answer on console too
}
} catch (Exception _e) {
throw _e instanceof RuntimeException ? (RuntimeException) _e : new RuntimeException(_e); } }
};
_t_0.start();
}
record(a);
return a.port;
}
static DialogHandler makeAndroid_makeDialogHandler(final String greeting, final StringFunc f) {
return new DialogHandler() {
public void run(final DialogIO io) {
if (!(publicCommOn() || io.isLocalConnection())) {
io.sendLine("Sorry, not allowed");
return;
}
String dialogID = randomID(8);
io.sendLine(greeting + " / Your ID: " + dialogID);
while (io.isStillConnected()) {
if (io.waitForLine()) {
final String line = io.readLineNoBlock();
String s = dialogID + " at " + now() + ": " + quote(line);
print(s);
if ("bye".equals(line)) {
io.sendLine("bye stranger");
return;
}
String answer = makeAndroid_getAnswer(line, f);
io.sendLine(answer == null ? "null" : answer);
//appendToLog(logFile, s);
}
}
}};
}
static String makeAndroid_getAnswer(String line, StringFunc f) {
String answer;
try {
answer = makeAndroid_fallback(line, f.get(line));
} catch (Throwable e) {
e = getInnerException(e);
e.printStackTrace();
answer = e.toString();
}
print("> " + answer);
return answer;
}
static String makeAndroid_fallback(String s, String answer) {
if (answer == null)
answer = (String) call(getJavaX(), "answer", s); // fall back to VM android
if (answer == null) answer = "?";
if (answer.indexOf('\n') >= 0 || answer.indexOf('\r') >= 0)
answer = quote(answer);
return answer;
}
static String _computerID;
public static String computerID() throws IOException {
if (_computerID == null) {
File file = new File(userHome(), ".tinybrain/computer-id");
_computerID = loadTextFile(file.getPath(), null);
if (_computerID == null) {
_computerID = makeRandomID(12);
saveTextFile(file.getPath(), _computerID);
}
}
return _computerID;
}
static Class getMainClass() { try {
return Class.forName("main");
} catch (Throwable __e) { throw __e instanceof RuntimeException ? (RuntimeException) __e : new RuntimeException(__e); }}
static Throwable getInnerException(Throwable e) {
while (e.getCause() != null)
e = e.getCause();
return e;
}
static boolean publicCommOn() {
return "1".equals(loadTextFile(new File(userHome(), ".javax/public-communication")));
}
static List