Added markov command ai
This commit is contained in:
@ -294,7 +294,26 @@ if ($DATA["message"]["from"]["is_bot"]) {
|
||||
$t = $DATA["message"]["text"];
|
||||
$uid = $DATA["message"]["from"]["id"];
|
||||
|
||||
|
||||
/*
|
||||
Feed the markov generator
|
||||
*/
|
||||
file_put_contents("markovdata.txt",trim($t)."\n",FILE_APPEND);
|
||||
/*
|
||||
Is markov overweight? remove lines
|
||||
*/
|
||||
$file = new SplFileObject("markovdata.txt");
|
||||
$i = 0;
|
||||
while (!$file->eof()) {
|
||||
$i++;
|
||||
$file->next();
|
||||
}
|
||||
if($i>1000000){
|
||||
$lines_to_strip=1000000-$i;
|
||||
$new_file = new SplFileObject('tempmark.txt', 'w');
|
||||
foreach (new LimitIterator(new SplFileObject('markovdata.txt'), $line_to_strip) as $line)
|
||||
$new_file->fwrite($line);
|
||||
}
|
||||
rename("tempmark.txt","markovdata.txt");
|
||||
|
||||
beg:
|
||||
switch ($DATA["message"]["chat"]["id"]) {
|
||||
@ -422,6 +441,11 @@ switch ($DATA["message"]["chat"]["id"]) {
|
||||
$url = $GLOBALS["config"]["lgbt"]["APIs"]["tpdne"] . "?v=" . time();
|
||||
API("sendChatAction", ["chat_id" => $DATA["message"]["chat"]["id"], "action" => "upload_photo"]);
|
||||
API("sendPhoto", ["chat_id" => $DATA["message"]["chat"]["id"], "photo" => $url, "reply_to_message_id" => $DATA["message"]["message_id"]]);
|
||||
} elseif ($t==".ai" || explode(" ", $t)[0] == ".ai") {
|
||||
if (!moduleOn(".ai", $DATA["message"]["chat"]["id"], $DATA, true)) break;
|
||||
require("markov.php");
|
||||
$n = (int) explode(" ", $t)[1];
|
||||
API("sendMessage", ["chat_id" => $DATA["message"]["chat"]["id"], "text" => markovT($n?:$GLOBALS["config"]["lgbt"]["markovdefault"])]);
|
||||
} elseif ($t == ".rave" || explode(" ", $t)[0] == ".rave") {
|
||||
if (!moduleOn(".rave", $DATA["message"]["chat"]["id"], $DATA, true)) break;
|
||||
$ms = explode("\n", $t, 3)[1] ?: explode(" ", $t, 2)[1];
|
||||
|
Reference in New Issue
Block a user