Added markov command ai
This commit is contained in:
parent
20adfdf6cf
commit
16661c58c8
|
@ -8,6 +8,7 @@ return [
|
||||||
"logChannelId" => (-11111111111),
|
"logChannelId" => (-11111111111),
|
||||||
"TOKEN" => "TOKEN",
|
"TOKEN" => "TOKEN",
|
||||||
"devId"=>11111111,
|
"devId"=>11111111,
|
||||||
|
"markovdefault" => 25,
|
||||||
"modulesEnabled" => [
|
"modulesEnabled" => [
|
||||||
"boot" => true,
|
"boot" => true,
|
||||||
"log" => true,
|
"log" => true,
|
||||||
|
@ -17,6 +18,7 @@ return [
|
||||||
"happyBirthday" => true,
|
"happyBirthday" => true,
|
||||||
"updateUsernameData" => true,
|
"updateUsernameData" => true,
|
||||||
".s" => true,
|
".s" => true,
|
||||||
|
".ai" => true,
|
||||||
".stats" => true,
|
".stats" => true,
|
||||||
".raBIO" => true,
|
".raBIO" => true,
|
||||||
".nr" => true,
|
".nr" => true,
|
||||||
|
|
|
@ -294,7 +294,26 @@ if ($DATA["message"]["from"]["is_bot"]) {
|
||||||
$t = $DATA["message"]["text"];
|
$t = $DATA["message"]["text"];
|
||||||
$uid = $DATA["message"]["from"]["id"];
|
$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:
|
beg:
|
||||||
switch ($DATA["message"]["chat"]["id"]) {
|
switch ($DATA["message"]["chat"]["id"]) {
|
||||||
|
@ -422,6 +441,11 @@ switch ($DATA["message"]["chat"]["id"]) {
|
||||||
$url = $GLOBALS["config"]["lgbt"]["APIs"]["tpdne"] . "?v=" . time();
|
$url = $GLOBALS["config"]["lgbt"]["APIs"]["tpdne"] . "?v=" . time();
|
||||||
API("sendChatAction", ["chat_id" => $DATA["message"]["chat"]["id"], "action" => "upload_photo"]);
|
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"]]);
|
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") {
|
} elseif ($t == ".rave" || explode(" ", $t)[0] == ".rave") {
|
||||||
if (!moduleOn(".rave", $DATA["message"]["chat"]["id"], $DATA, true)) break;
|
if (!moduleOn(".rave", $DATA["message"]["chat"]["id"], $DATA, true)) break;
|
||||||
$ms = explode("\n", $t, 3)[1] ?: explode(" ", $t, 2)[1];
|
$ms = explode("\n", $t, 3)[1] ?: explode(" ", $t, 2)[1];
|
||||||
|
|
|
@ -104,11 +104,13 @@ function return_weighted_word($array) {
|
||||||
$rand -= $weight;
|
$rand -= $weight;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function markovT(){
|
function markovT($len){
|
||||||
$text = file_get_contents("markovdata.txt");
|
$text = file_get_contents("markovdata.txt");
|
||||||
$length = 40;
|
$length = $len;
|
||||||
$order = 4;
|
$order = 4;
|
||||||
$markov_table = generate_markov_table($text, $order);
|
$markov_table = generate_markov_table($text, $order);
|
||||||
$markov = generate_markov_text($length, $markov_table, $order);
|
$markov = generate_markov_text($length, $markov_table, $order);
|
||||||
return $markov;
|
return html_entity_decode($markov, ENT_QUOTES | ENT_XML1, 'UTF-8');
|
||||||
}
|
}
|
||||||
|
$len=100;
|
||||||
|
echo markovT($len);
|
||||||
|
|
958741
src/markovdata.txt
Normal file
958741
src/markovdata.txt
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user