summaryrefslogtreecommitdiffstats
path: root/mentions
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
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')
-rw-r--r--mentions/banned_subs.txt0
-rw-r--r--mentions/banned_users.txt0
-rw-r--r--mentions/index.php27
-rwxr-xr-xmentions/mentions.php55
-rw-r--r--mentions/processed.txt0
-rwxr-xr-xmentions/worddetect.php38
6 files changed, 120 insertions, 0 deletions
diff --git a/mentions/banned_subs.txt b/mentions/banned_subs.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/mentions/banned_subs.txt
diff --git a/mentions/banned_users.txt b/mentions/banned_users.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/mentions/banned_users.txt
diff --git a/mentions/index.php b/mentions/index.php
new file mode 100644
index 0000000..005efb0
--- /dev/null
+++ b/mentions/index.php
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<html lang=en>
+ <head>
+ <meta charset=UTF-8 />
+ <meta name=viewport content="width=device-width,initial-scale=1.0" />
+ <title>
+ ImgLinkBot
+ </title>
+ <style>
+ body {
+ background-color: black;
+ margin: 0;
+ padding: 0
+ }
+ img {
+ width: 100%
+ }
+ </style>
+ </head>
+ <body>
+ <?php
+ foreach(explode(",", $_REQUEST["i"]) as $a) {
+ echo '<img src="https://i.redd.it/'.htmlspecialchars($a).'" />';
+ }
+ ?>
+ </body>
+</html>
diff --git a/mentions/mentions.php b/mentions/mentions.php
new file mode 100755
index 0000000..c3d095b
--- /dev/null
+++ b/mentions/mentions.php
@@ -0,0 +1,55 @@
+#!/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/ImgLinkBot](/u/ImgLinkBot)";
+ while (true) {
+ $mentions = $o->fetch("mentions");
+ if ($mentions < 0) {
+ file_put_contents("log.txt", '[mentions.php] ERROR in $mentions'."\n", FILE_APPEND);
+ continue;
+ }
+ foreach($mentions["data"]["children"] as $mention) {
+ $processed = file_get_contents("processed.txt");
+ if ($processed === false) {
+ file_put_contents("log.txt", "[mentions.php] ERROR: can't read processed.txt\n", FILE_APPEND);
+ continue;
+ }
+ if (in_array($mention["data"]["id"], explode("\n", $processed))) {
+ continue;
+ }
+ if (in_array($mention["data"]["subreddit"], explode("\n", file_get_contents("banned_subs.txt")))) {
+ continue;
+ }
+ if (in_array($mention["data"]["author"], explode("\n", file_get_contents("banned_users.txt")))) {
+ continue;
+ }
+ $post = explode("/", $mention["data"]["context"])[4];
+ $post = $o->fetch("post", $post);
+ var_dump($post);
+ if ($post < 0) {
+ file_put_contents("log.txt", '[mentions.php] ERROR in $post'."\n", FILE_APPEND);
+ continue;
+ }
+ $post = $post[0]["data"]["children"][0];
+ $parent = "t1_".$mention["data"]["id"];
+ if (!file_put_contents("processed.txt", $mention["data"]["id"]."\n", FILE_APPEND)) {
+ file_put_contents("log.txt", "[mentions.php] ERROR mentions_processed.txt PUT\n", FILE_APPEND);
+ continue;
+ }
+ if (!in_array("media_metadata", array_keys($post["data"]))) {
+ $o->comment("Error: This post does not appear to be a gallery.$botsignature", $parent);
+ } else {
+ $imgs = "";
+ foreach ($post["data"]["media_metadata"] as $metadata) {
+ $imgs .= get_string_between($metadata["s"]["u"], "dd.it/", "?width=").",";
+ }
+ $imgs = substr($imgs, 0, -1); // da odstranimo zadnjo vejico
+ $o->comment("[https://imglinkbot.ž.ga/?i=$imgs](https://imglinkbot.xn--jha.ga/?i=$imgs)$botsignature", $parent);
+ }
+ }
+ sleep(10);
+ }
+?>
diff --git a/mentions/processed.txt b/mentions/processed.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ 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);
+ }
+?>