Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $ret = chr(10);
- echo "start" . chr(10);
- chdir(dirname(__FILE__));
- date_default_timezone_set("UTC");
- $warnOnly = array(
- "Marvel", "india", "denverlist", "Minecraft360", "ksrp", "MinecraftOne", "TheKitRoom", "Filmmakers", "Advice", "flipnotestudio3d"
- , "2016_elections", "GayPornCentral", "rLoop", "Musicthemetime", "gayyoungold", "LoveLive", "lspdfr", "daddypics"
- , "intj", "CannabisExtracts", "introvert", "artstore", "Dogtraining", "NarutoNinjaStorm" // , "Animedubs"
- );
- $reportApproved = array(
- "animation"
- );
- $onlySelfPosts = array(
- "Animedubs"
- );
- $subBlacklist = array("weightroom");
- $customWarnings = array();
- $customWarnings["india"] = "Hi %%AUTHOR%%, thanks for you submission." . chr(10) . chr(10) . "Looks like you forgot to add a flair to your post. %%SUBREDDIT%% requires all posts to be flaired so please add it by using the method explained below. This comment will be deleted once flair has been added." . chr(10) . chr(10) . "To add flair to your post, open it and click the button labelled flair beneath your title. From the menu, select the most appropriate category, and then hit save. Thanks!";
- $customWarnings["UnlimitedBestOF"] = "Hi %%AUTHOR%%, thanks for you submission to /r/UnlimitedBestOF!" . chr(10) . chr(10) . "Looks like you forgot to add a flair to your post. /r/UnlimitedBestOF requires flair on all posts so we can sort them by genre. Your post has been removed, but it will be reapproved (and this comment deleted) once you add flair." . chr(10) . chr(10) . "To add flair, open your post and click the button labelled flair beneath your title. From the menu, select the most appropriate genre, and then click save. Thanks!";
- $customWarnings["chile"] = "r/chile requires you to **flair your post**! This post has been automatically removed but will be reapproved (and this comment deleted) once flair has been added." . chr(10) . chr(10) . "To add flair to your post, open it and click the button labelled ``flair`` beneath your title. From the menu, select the most appropriate category, and then hit ``save``. You do *not* need to delete or resubmit your post!" . chr(10) . chr(10) . "¡/r/chile pide que le pongas flair a tu post! Este post ha sido automáticamente eliminado pero será reaprobado (y este comentario borrado) una vez que le agregues flair (o adornos)." . chr(10) . chr(10) . "Para agregar flair a tu post, ábre su página de comentarios y haz click en el botón de flair (adornos), abajo del título. Del menú, elige la categoría más apropiada, y después apreta Save (guardar). ¡No necesitas ni borrar ni re-enviar tu post!" . chr(10) . chr(10) . "No me culpes a mí, [solo soy un bot](/28tspq).";
- $customWarnings["ConspiracyGrumps"] = "r/ConspiracyGrumps requires you to flair your post! This post has been automatically removed but will be re-approved (and this comment deleted) once flair has been added. This is to make sure silly posts, and serious posts are able to be differentiated!";
- $customWarnings["Webseries"] = "r/Webseries requires you to **flair your post**!" . chr(10) . chr(10) . "This post has been automatically removed but will be reapproved (and this comment deleted) once flair has been added. To add flair to your post, open it and click the button labelled ``GENRE/FLAIR`` beneath your title. From the menu, select the most appropriate category ^*descriptions ^can ^be ^found ^in ^the ^sidebar and then hit ``save``." . chr(10) . chr(10) . "You do not need to delete or resubmit your post **unless you forgot to place a TIMESTAMP at the end of your video links!**";
- $customWarnings["2016_elections"] = "r/2016_elections prefers that you **flair your post**! This comment will be deleted once flair has been added." . chr(10) . chr(10) . "To add flair to your post, open it and click the button labelled flair beneath your title. From the menu, select the most appropriate category, and then hit save. Please [read our Wiki](/r/2016_elections/wiki/index) for more information on flairs.";
- $customWarnings["rLoop"] = "Hello!" . chr(10) . chr(10) . "Just a friendly reminder, your post must have flair! It helps us manage things. Once you flair your post, this comment will be removed." . chr(10) . chr(10) . "If there's a problem, please [contact the mods](https://www.reddit.com/message/compose?to=%2Fr%2FrLoop).";
- // $customWarnings["Animedubs"] = "It apears that your post is **missing a flair**! Please take 5 seconds out of your busy day to add one and /r/AnimeDubs will be forever in your debt." . chr(10) . chr(10) . "**Not sure how to add a flair? [This quick tutorial wll show you how](http://i.imgur.com/6rBxJK4.png)**." . chr(10) . chr(10) . "Here's a list of all the flairs and what they mean:" . chr(10) . chr(10) . "* **SPOILERS** - If you want to post spoilers about a show without the need to use the spoiler tag, your post must have this flair. It's also important that you state the name of the show you mean to spoil in the title of the post or in **Bold** at the very top of the post so people don't accidentally read your spoiler." . chr(10) . chr(10) . "* **Meta** - For posts about the subreddit itself." . chr(10) . chr(10) . "* **Request** - For posts where you are requesting help to find new anime to watch. Can also be used if you are just generally requesting help with something." . chr(10) . chr(10) . "* **Suggestion** - For when **you want to suggest** an anime for **other people** to watch. Can also be used for general sugestions to other users." . chr(10) . chr(10) . "* **Question** - For general questions that don't fit any of the other flairs." . chr(10) . chr(10) . "* **Discussion** - For general discussions about any topic that doesn't fit the Meta flair. Typically for discussing a show, dub or voice actor." . chr(10) . chr(10) . "* **Fandub** - If your post is about any unoficial dub, be it for shows, songs, or abridged series, use this flair." . chr(10) . chr(10) . "This comment will be deleted once a flair has been added. Please [contact the moderators of this subreddit](https://www.reddit.com/message/compose?to=%2Fr%2FAnimedubs) if you have any questions or concerns.";
- $customWarnings["Animedubs"] = "It apears that your post is **missing a flair**! Please take 5 seconds out of your busy day to add one and r/AnimeDubs will be forever in your debt. " . chr(10) . chr(10) . "**Not sure how to add a flair? [this quick tutorial wll show you how](http://i.imgur.com/6rBxJK4.png)**" . chr(10) . chr(10) . "Here's a list of all the flairs and what they mean:" . chr(10) . chr(10) . "* **SPOILERS** - If you want to post spoilers about a show without the need to use the spoiler tag your post must have this flair. It's also important that you state the name of the show you mean to spoil in the title of the post or in **Bold** at the very top of the post so people don't acsedentaly read your spoiler. " . chr(10) . chr(10) . "* **Meta** - for post about the subreddit itself." . chr(10) . chr(10) . "* **Reqiest** - For posts where you are requesting help to find new anime to watch. Can also be used if you are just generally requesting help with something. " . chr(10) . chr(10) . "* **Suggestion** - For when **you want to suggest** an anime for **other people** to watch. Can also be used for generall sugestions to other users. " . chr(10) . chr(10) . "* **Question** - For general questions that don't fit any of the other flairs." . chr(10) . chr(10) . "* **Discussion** - For general discussions about any topic that doesn't fit the Meta flair. Typically for discussing a show, dub or voice actor." . chr(10) . chr(10) . "* **Fandub** - If your post is about any unoficial dub, be it for shows, songs or abridge series, use this flair." . chr(10) . chr(10) . "This comment will be deleted once a flair has been added. Please [contact the moderators of this subreddit](/message/compose?to=%2Fr%2FAnimedubs) if you have any questions or concerns. ";
- $customWarnings["LoveLive"] = "r/LoveLive requires you to **flair your post**! This comment will be deleted once flair has been added." . chr(10) . chr(10) . "To add flair to your post, open it and click the red button labelled ``Please Select a Link Flair!`` beneath your title. From the menu, select the most appropriate category, and then hit ``save``. You do *not* need to delete or resubmit your post!" . chr(10) . chr(10) . "For more information, please visit the [relevant wiki page](/r/LoveLive/wiki/flairs).";
- $customWarnings["lspdfr"] = "**Reminder: you have to flair your post. If you do not, a mod will remove your post.** This comment will be deleted once flair has been added.";
- $customWarnings["childfree"] = "Hello!" . chr(10) . chr(10) . "Your post hasn't been assigned a proper post flair yet, which is a violation of this subreddit's rule #4. [Flair assignation instructions are in the sidebar](https://www.reddit.com/r/childfree/comments/3n4i2i/status_of_the_subreddit_flair_and_filter_system/). This post has been automatically removed, but it will be reapproved (and this comment will disappear) once it has a flair." . chr(10) . chr(10) . "* **If you're a mobile user**, and your mobile Reddit application **doesn't have a flair menu**, flair can be assigned automatically as the option is not always available on mobile Reddit applications. To use this mechanism, please delete your submission and re-submit it with the necessary key word in its title, as titles are not editable on Reddit." . chr(10) . chr(10) . "* If you're *not* a mobile user or if you're a mobile user whose mobile Reddit application **does support a post flair system**, please select the most appropriate flair from the menu and hit ``save``. Thanks! :)";
- $customWarnings["MarioMaker"] = "r/MarioMaker requires you to flair your post! This post has been automatically removed but will be reapproved (and this comment deleted) once flair has been added." . chr(10) . chr(10) . "To add flair to your post, open it and click the button labelled flair beneath your title. From the menu, select the most appropriate category, and then hit save. You do not need to delete or resubmit your post!" . chr(10) . chr(10) . "For further information on adding flairs including instructions for those on mobile apps, [please refer to our guide.](https://www.reddit.com/r/MarioMaker/wiki/tags)";
- $customWarnings["intj"] = "r/INTJ prefers that you **flair your post**! This comment will be deleted once flair has been added." . chr(10) . chr(10) . "To add flair to your post, open it and click the button labelled ``flair`` beneath your title. From the menu, select the most appropriate category, and then hit ``save``.";
- $customWarnings["CannabisExtracts"] = "/r/CannabisExtracts prefers that you **flair your post**! This comment will be deleted once flair has been added." . chr(10) . chr(10) . "To add flair to your post, open it and click the button labelled ``flair`` beneath your title. From the menu, select the most appropriate category, and then hit ``save``. You do *not* need to delete or resubmit your post!";
- $customWarnings["introvert"] = "r/Introvert prefers that you **flair your post**! This comment will be deleted once flair has been added." . chr(10) . chr(10) . "To add flair to your post, open it and click the button labelled ``flair`` beneath your title. From the menu, select the most appropriate category, and then hit ``save``.";
- $customWarnings["artstore"] = "This sub provides a flair system for easier post browsing and increased visibility of your post. To add flair to your post, open it and click the button labelled flair beneath your post title, select the appropriate category and click save. This will add the selected color-coded flair to your post title.";
- $customWarnings["Naruto"] = "r/Naruto requires you to **flair your post**! This post has been automatically removed but will be reapproved (and this comment deleted) once flair has been added." . chr(10) . chr(10) . "To add flair to your post, open it and click the button labelled ``flair`` beneath your title. From the menu, select the most appropriate category, and then hit ``save``. You do *not* need to delete or resubmit your post!" . chr(10) . chr(10) . "Click [here](/r/Naruto/wiki/linkflair) to see what link flairs to use. If you're a mobile user, click [here](/r/naruto/wiki/mobilelinkflair) to see how to flair on the go.";
- $customWarnings["OnePieceTC"] = "r/OnePieceTC requires you to flair your post!" . chr(10) . chr(10) . "This post has been automatically removed but will be re-approved (and this comment deleted) once a flair has been set." . chr(10) . chr(10) . "Please refer to [this guideline](/r/OnePieceTC/wiki/linkflairs) on how to properly set the right flair. You do not need to delete or resubmit your post!";
- require_once("reddit-php-sdk-master/reddit.php");
- $reddit = new reddit("flair_your_post_bot", "dhCqLUeK", "t2_h36b8");
- if ($reddit === false) die("login failure");
- // get latest comments
- $response = $reddit->getListing("user/flair_your_post_bot/comments", 100);
- if (!is_object($response)) die("DEATH ON my comments");
- else if (!isset($response->data)) { echo "no data obj!" . chr(10); print_r($response); die(); }
- $data = $response->data;
- $posts = $data->children;
- $commentIDs = array();
- $titlesURL = 'by_id/';
- foreach ($posts as $key => $val) {
- $data = $val->data;
- $commentIDs[$data->link_id] = $data->name;
- $titlesURL .= (strlen($titlesURL) < 7 ? "" : ",") . $data->link_id;
- }
- // get posts from mod subs
- $response = $reddit->getListing("r/mod/new", 100);
- if (!is_object($response) || !is_object($response->data)) die("DEATH ON mod/new");
- $data = $response->data;
- $posts = $data->children;
- echo "found " . count($posts) . " posts" . chr(10);
- foreach ($posts as $key => $val) {
- $data = $val->data;
- $linkflairclass = $data->link_flair_css_class;
- $linkflairtext = $data->link_flair_text;
- $linkid = $data->name;
- $subname = $data->subreddit;
- $approvedby = $data->approved_by;
- $removedby = $data->banned_by;
- $distinguished = $data->distinguished;
- // $id = $data->id;
- $author = $data->author;
- // $subid = $data->subreddit_id;
- $created = $data->created_utc;
- $timeDiff = abs($created - time());
- if ($timeDiff < 60 || $timeDiff > 360) { continue; } // more than a minute old (but less than 6 minutes old)?
- // echo "timediff: " . $timeDiff . ", " . $created . " v. " . time() . chr(10);
- if (
- strcmp($distinguished, "") === 0
- && strcmp($removedby, "") === 0
- && strcmp($linkflairclass, "") === 0
- && strcmp($linkflairtext, "") === 0
- && (strcmp($approvedby, "") === 0 || strcmp($approvedby, "AutoModerator") === 0)
- && (!in_array($subname, $onlySelfPosts) || $data->selftext != "")
- ) { // not removed and no flair
- // if (isset($customWarnings[$subname])) {
- // echo "custom warning " . $linkid . " from /r/" . $subname . chr(10);
- // $response = $reddit->addComment($linkid, str_replace("%%SUBREDDIT%%", $subname, str_replace("%%AUTHOR%%", $author, $customWarnings[$subname])) . chr(10) . chr(10) . "*Don't blame me, [I'm just a bot](/28tspq) from [radd.it](http://radd.it)*.");
- // }
- // else if (in_array($subname, $warnOnly)) {
- // echo "warning post " . $linkid . " from /r/" . $subname . chr(10);
- // $response = $reddit->addComment($linkid, "/r/" . $subname . " prefers that you **flair your post**! This comment will be deleted once flair has been added." . chr(10) . chr(10) . "To add flair to your post, open it and click the button labelled ``flair`` beneath your title. From the menu, select the most appropriate category, and then hit ``save``. You do *not* need to delete or resubmit your post!" . chr(10) . chr(10) . "*Don't blame me, [I'm just a bot](/28tspq) from [radd.it](http://radd.it)*.");
- // }
- // else {
- // echo "removing post " . $linkid . " from /r/" . $subname . chr(10);
- // $response = $reddit->addComment($linkid, "/r/" . $subname . " requires you to **flair your post**! This post has been automatically removed but will be reapproved (and this comment deleted) once flair has been added." . chr(10) . chr(10) . "To add flair to your post, open it and click the button labelled ``flair`` beneath your title. From the menu, select the most appropriate category, and then hit ``save``. You do *not* need to delete or resubmit your post!" . chr(10) . chr(10) . "*Don't blame me, [I'm just a bot](/28tspq) from [radd.it](http://radd.it)*.");
- // }
- $response = $reddit->addComment($linkid, "Flair your post if you want to. It's [a free world](/r/chrisolivertimes), baby!");
- if (isset($response->jquery) && isset($response->jquery[18]) && isset($response->jquery[18][3]) && isset($response->jquery[18][3][0]) && isset($response->jquery[18][3][0][0]) && isset($response->jquery[18][3][0][0]->data) && isset($response->jquery[18][3][0][0]->data->id))
- {
- $commentID = $response->jquery[18][3][0][0]->data->id;
- $reddit->distinguish($commentID);
- }
- // if (!in_array($subname, $warnOnly)) $reddit->removeStory($linkid);
- }
- // else echo "ok " . $linkid . chr(10);
- }
- die();
- // get mod log and recheck previously removed posts
- $modlog = $reddit->getListing("r/mod/about/log?type=removelink&mod=flair_your_post_bot", 100);
- if (is_object($modlog) && is_object($modlog->data))
- {
- echo "got modlog" . chr(10);
- $logs = $modlog->data->children;
- // merge with posts found from comments.. for no real good reason.
- foreach ($logs as $key => $val)
- if (strpos($titlesURL, $val->data->target_fullname) == false)
- $titlesURL .= (strlen($titlesURL) < 7 ? "" : ",") . $val->data->target_fullname;
- }
- // die($titlesURL);
- if (strlen($titlesURL) > 6) {
- $response = $reddit->getListing($titlesURL, 100);
- if (is_object($response)) {
- $data = $response->data;
- $posts = $data->children;
- foreach ($posts as $key => $val) {
- $data = $val->data;
- $author = $data->author;
- $linkflairclass = $data->link_flair_css_class;
- $linkflairtext = $data->link_flair_text;
- $linkid = $data->name;
- $subname = $data->subreddit;
- $approvedby = $data->approved_by;
- $removedby = $data->banned_by;
- // if (in_array($author, $banned, true)) continue;
- // echo "check post " . $linkid . " in /r/" . $subname . chr(10);
- // echo "approvedby: " . $approvedby . chr(10);
- // echo "removedby: " . $removedby . chr(10);
- // echo "class: " . $linkflairclass . chr(10);
- // echo "text: " . $linkflairtext . chr(10) . chr(10);
- if (
- strcmp($author, "[deleted]") === 0
- || strcmp($linkflairclass, "") !== 0
- || strcmp($linkflairtext, "") !== 0
- ) { // removed but now with flair!
- if (isset($commentIDs[$linkid])) $reddit->deleteStory($commentIDs[$linkid]);
- if (
- !in_array($subname, $warnOnly, true)
- && strcmp($author, "[deleted]") !== 0
- && strcmp($removedby, "flair_your_post_bot") === 0
- && (strcmp($approvedby, "") === 0 || strcmp($approvedby, "AutoModerator") === 0)
- ) {
- echo "reapproving post " . $linkid . " in /r/" . $subname . chr(10);
- $reddit->approveStory($linkid);
- if (in_array($subname, $reportApproved, true)) $reddit->reportThing($linkid, "Approved by FYPbot.");
- }
- }
- }
- }
- }
- // get messages and autoaccept any mod invites
- $response = $reddit->getMessagesUnread();
- if (!is_object($response)) die("DEATH ON MESSAGES"); //
- $fiveMinAgo = strtotime("5 minutes ago");
- $data = $response->data;
- $msgs = $data->children;
- foreach ($msgs as $item)
- {
- $text = "";
- $data = $item->data;
- if ($data->created_utc < $fiveMinAgo) continue; // ignore old requests.
- $name = $data->name;
- $body = trim(html_entity_decode($data->body), "*");
- if (strpos($body, "you are invited to become a moderator of [/r/") !== false) {
- $rPos = strpos($body, "[/r/") + 4;
- $pPos = strpos($body, ":", $rPos);
- $newSub = substr($body, $rPos, $pPos - $rPos);
- echo "invited to mod " . $newSub . chr(10);
- if (!in_array($newSub, $subBlacklist, true)) {
- $reddit->modAccept($newSub);
- $reddit->sendMessage("/r/" . $newSub, "/u/flair_your_post_bot now active!", "This bot will now remove any posts older than a minute that haven't been flaired. Please [see this post](/28tspq) for details on how it works." . chr(10) . chr(10) . "flairbot is provided as-is. Customizations are no longer available.");
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement