summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--main.php19
-rw-r--r--mentions/banned_subs.txt (renamed from bot/banned_subs.txt)0
-rw-r--r--mentions/banned_users.txt (renamed from bot/banned_users.txt)0
-rw-r--r--mentions/index.php (renamed from bot/index.php)0
-rwxr-xr-xmentions/mentions.php (renamed from bot/mentions.php)2
-rw-r--r--mentions/processed.txt (renamed from bot/processed.txt)0
-rwxr-xr-xmentions/worddetect.php38
-rw-r--r--worddetect/banned_subs.txt0
-rw-r--r--worddetect/banned_users.txt0
-rw-r--r--worddetect/processed.txt0
-rwxr-xr-xworddetect/worddetect.php38
11 files changed, 95 insertions, 2 deletions
diff --git a/main.php b/main.php
index 31dee80..e453cae 100644
--- a/main.php
+++ b/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") {
diff --git a/bot/banned_subs.txt b/mentions/banned_subs.txt
index e69de29..e69de29 100644
--- a/bot/banned_subs.txt
+++ b/mentions/banned_subs.txt
diff --git a/bot/banned_users.txt b/mentions/banned_users.txt
index e69de29..e69de29 100644
--- a/bot/banned_users.txt
+++ b/mentions/banned_users.txt
diff --git a/bot/index.php b/mentions/index.php
index 005efb0..005efb0 100644
--- a/bot/index.php
+++ b/mentions/index.php
diff --git a/bot/mentions.php b/mentions/mentions.php
index 3b87abf..c3d095b 100755
--- a/bot/mentions.php
+++ b/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) {
diff --git a/bot/processed.txt b/mentions/processed.txt
index e69de29..e69de29 100644
--- a/bot/processed.txt
+++ b/mentions/processed.txt
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);
+ }
+?>
diff --git a/worddetect/banned_subs.txt b/worddetect/banned_subs.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/worddetect/banned_subs.txt
diff --git a/worddetect/banned_users.txt b/worddetect/banned_users.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/worddetect/banned_users.txt
diff --git a/worddetect/processed.txt b/worddetect/processed.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/worddetect/processed.txt
diff --git a/worddetect/worddetect.php b/worddetect/worddetect.php
new file mode 100755
index 0000000..9e63526
--- /dev/null
+++ b/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);
+ }
+?>