summaryrefslogtreecommitdiffstats
path: root/mentions/worddetect.php
diff options
context:
space:
mode:
authorsijanec <sijanecantonluka@gmail.com>2020-11-03 23:27:34 +0100
committersijanec <sijanecantonluka@gmail.com>2020-11-03 23:27:34 +0100
commit13b43f96111d4100ac0c21e81d91c2f0ad2a7577 (patch)
tree4b44896b63a9c09b4fcaa46c95a821da2910ed90 /mentions/worddetect.php
parentcss (diff)
downloadoldredditclient-13b43f96111d4100ac0c21e81d91c2f0ad2a7577.tar
oldredditclient-13b43f96111d4100ac0c21e81d91c2f0ad2a7577.tar.gz
oldredditclient-13b43f96111d4100ac0c21e81d91c2f0ad2a7577.tar.bz2
oldredditclient-13b43f96111d4100ac0c21e81d91c2f0ad2a7577.tar.lz
oldredditclient-13b43f96111d4100ac0c21e81d91c2f0ad2a7577.tar.xz
oldredditclient-13b43f96111d4100ac0c21e81d91c2f0ad2a7577.tar.zst
oldredditclient-13b43f96111d4100ac0c21e81d91c2f0ad2a7577.zip
Diffstat (limited to 'mentions/worddetect.php')
-rwxr-xr-xmentions/worddetect.php38
1 files changed, 38 insertions, 0 deletions
diff --git a/mentions/worddetect.php b/mentions/worddetect.php
new file mode 100755
index 0000000..9e63526
--- /dev/null
+++ b/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);
+ }
+?>