Browse Source

dodal worddetect za pozigalca ampak ni narejen do konca

master
sijanec 1 year ago
parent
commit
13b43f9611
  1. 19
      main.php
  2. 0
      mentions/banned_subs.txt
  3. 0
      mentions/banned_users.txt
  4. 0
      mentions/index.php
  5. 2
      mentions/mentions.php
  6. 0
      mentions/processed.txt
  7. 38
      mentions/worddetect.php
  8. 0
      worddetect/banned_subs.txt
  9. 0
      worddetect/banned_users.txt
  10. 0
      worddetect/processed.txt
  11. 38
      worddetect/worddetect.php

19
main.php

@ -209,6 +209,7 @@ Errors:
}
if ($limit>100) {
echo "\n[oldredditclient] WARN get(): multipage not implemented (limit>100)!\n";
return -4;
}
$ch = $this->ch;
switch($what) {
@ -225,7 +226,7 @@ Errors:
}
$arr = json_decode($response, true, 512);
return $arr;
break;
break;
case "post":
curl_setopt($ch, CURLOPT_URL, $this->redditurl.$value.".json");
curl_setopt($ch, CURLOPT_POST, 0);
@ -239,8 +240,24 @@ Errors:
}
$arr = json_decode($response, true, 512);
return $arr;
break; // unreachable code amirite
case "comments": // value=r/Slovenia || value=u/first
curl_setopt($ch, CURLOPT_URL, $this->redditurl.$value."/comments/.json");
curl_setopt($ch, CURLOPT_POST, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"X-Modhash: ".$this->modhash,
"X-ContactBotDeveloper: ".$this->adminemail
));
$response = curl_exec($ch);
if (curl_getinfo($ch, CURLINFO_RESPONSE_CODE) != 200) {
return false;
}
$arr = json_decode($response, true, 512);
return $arr;
break; // te breake delam nagonsko
default:
return -5;
break;
}
}
public function comment($text = "oldredditClient", $in_reply_to = "jd2fm5") {

0
bot/banned_subs.txt → mentions/banned_subs.txt

0
bot/banned_users.txt → mentions/banned_users.txt

0
bot/index.php → mentions/index.php

2
bot/mentions.php → mentions/mentions.php

@ -4,7 +4,7 @@
$o = new oldredditClient();
$o->setusername(getenv("orC_user"));
$o->setpassword(getenv("orC_pass"));
$botsignature = "\n\n-- [/u/ImgLinkBot](/u/ImgLinkBot) | [ImgLinkBot.ž.ga](https://imglinkbot.xn--jha.ga/)";
$botsignature = "\n\n-- [/u/ImgLinkBot](/u/ImgLinkBot)";
while (true) {
$mentions = $o->fetch("mentions");
if ($mentions < 0) {

0
bot/processed.txt → mentions/processed.txt

38
mentions/worddetect.php

@ -0,0 +1,38 @@
#!/usr/bin/env php
<?php
require_once("../main.php");
$o = new oldredditClient();
$o->setusername(getenv("orC_user"));
$o->setpassword(getenv("orC_pass"));
$botsignature = "\n\n-- [/u/PozigalecBot](/u/PozigalecBot)";
while (true) {
$comments = $o->fetch("comments");
if ($comments < 0) {
file_put_contents("log.txt", '[worddetect.php] ERROR in $comments'."\n", FILE_APPEND);
continue;
}
foreach($comment["data"]["children"] as $comment) {
$processed = file_get_contents("processed.txt");
if ($processed === false) {
file_put_contents("log.txt", "[worddetect.php] ERROR: can't read processed.txt\n", FILE_APPEND);
continue;
}
if (in_array($comment["data"]["id"], explode("\n", $processed))) {
continue;
}
if (in_array($comment["data"]["subreddit"], explode("\n", file_get_contents("banned_subs.txt")))) {
continue;
}
if (in_array($comment"data"]["author"], explode("\n", file_get_contents("banned_users.txt")))) {
continue;
}
$parent = "t1_".$comment["data"]["id"];
if (!file_put_contents("processed.txt", $comment["data"]["id"]."\n", FILE_APPEND)) {
file_put_contents("log.txt", "[worddetect.php] ERROR mentions_processed.txt PUT\n", FILE_APPEND);
continue;
}
$o->comment("Pa je zašvicu ful! $botsignature", $parent); // TODO!
}
sleep(10);
}
?>

0
worddetect/banned_subs.txt

0
worddetect/banned_users.txt

0
worddetect/processed.txt

38
worddetect/worddetect.php

@ -0,0 +1,38 @@
#!/usr/bin/env php
<?php
require_once("../main.php");
$o = new oldredditClient();
$o->setusername(getenv("orC_user"));
$o->setpassword(getenv("orC_pass"));
$botsignature = "\n\n-- [/u/PozigalecBot](/u/PozigalecBot)";
while (true) {
$comments = $o->fetch("comments");
if ($comments < 0) {
file_put_contents("log.txt", '[worddetect.php] ERROR in $comments'."\n", FILE_APPEND);
continue;
}
foreach($comment["data"]["children"] as $comment) {
$processed = file_get_contents("processed.txt");
if ($processed === false) {
file_put_contents("log.txt", "[worddetect.php] ERROR: can't read processed.txt\n", FILE_APPEND);
continue;
}
if (in_array($comment["data"]["id"], explode("\n", $processed))) {
continue;
}
if (in_array($comment["data"]["subreddit"], explode("\n", file_get_contents("banned_subs.txt")))) {
continue;
}
if (in_array($comment"data"]["author"], explode("\n", file_get_contents("banned_users.txt")))) {
continue;
}
$parent = "t1_".$comment["data"]["id"];
if (!file_put_contents("processed.txt", $comment["data"]["id"]."\n", FILE_APPEND)) {
file_put_contents("log.txt", "[worddetect.php] ERROR mentions_processed.txt PUT\n", FILE_APPEND);
continue;
}
$o->comment("Pa je zašvicu ful! $botsignature", $parent); // TODO!
}
sleep(10);
}
?>
Loading…
Cancel
Save

Med zimskimi počitnicami so pričakovani občasni izpadi podomrežja O, ker bodo izvajana testiranja varnosti komunikacijsko-informacijske opreme.