Warning: session_start(): open(/var/lib/php/sessions/sess_dv6lfq9s9aiahrb7ngordm322j, 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
!7
cmodule2 FollowSkypeBot > DynPrintLog {
switchable bool uploadEnabled;
switchable double answerInterval = 3.0;
transient Q uploadQ;
File logFile() {
ret userDir("dev/skype-bot/skype.log");
}
start-thread {
uploadQ = dm_startQ();
printFileInfo(logFile());
tailFileLinewise(logFile(), 1000, voidfunc(S line) {
handleLine(line);
});
print("Listening to log " + stringIf(uploadEnabled, " with upload"));
dm_startThread(r postAnswers);
}
void postAnswers {
while true {
sleepSeconds(answerInterval);
S file = "/root/dev/skype-bot/msgs-to-send.json";
pcall {
L msgs = cast jsonDecode(loadPageSilently("https://bea.gazelle.rocks/beaHTML/127493?markSent=1"));
if (nempty(msgs)) {
print("Waiting for file to disappear: " + file);
while (fileExists(file)) sleepSeconds(1);
saveTextFile(file, jsonEncode(msgs));
print("Sent msgs to bot.");
}
}
}
}
void processWholeLog {
for (S line : linesFromFile(logFile()))
handleLine(line);
}
void handleLine(S line) pcall {
new Matches m;
if (startsWith(line, "Message: ", m)) {
//print(m.rest());
Map map = jsonDecodeMap(m.rest());
//pnl(map);
Map resource = cast mapGet(map, "resource");
//pnl(resource);
S displayName = cast mapGet(resource, "imdisplayname");
S content = cast mapGet(resource, "content");
if (nempty(content)) {
S cleaned = cleanSkypeMsg(content);
print("Cleaned: " + cleaned);
if (uploadEnabled) uploadQ.add(r {
S info = "Skype";
if (nempty(displayName)) info += " (User " + displayName + ")";
gazelleBEA_uploadInput(cleaned, info);
});
}
}
}
}