Giter Site home page Giter Site logo

imagesofnetwork's Introduction

ImagesOfNetwork

Tools for managing the ImagesOfNetwork on reddit

Getting Started

Laying out the steps for getting it running here.

Install package

$ git clone [email protected]:amici-ursi/ImagesOfNetwork.git
$ cd ImagesOfNetwork
$ virtualenv -v venv-ion -p python3
$ source venv-ion/bin/activate
$ python setup.py install

NOTE: If you're developing rather than deploying, go ahead and use python setup.py develop instead. That way, as you make changes to the source, they'll get picked up as you go.

Reddit

These tools make extensive use of the Reddit API (duh), so lets make sure that that's all set up. Head on over to your apps preferences and click the button to create a developer app. You should see 5 fields here.

  • name: Anything you want, you're the only one that's going to see it.
  • radio buttons: Make sure script is selected
  • description: Again just for you. You can even leave it blank.
  • about url: ditto
  • redirect url: This one's important for setting up OAuth. The tools are set up to use http://127.0.0.1:65010/authorize_callback

Click create app, and note the series of digits under "personal use script". that's your client id. Also, you'll need to keep tabs on the value of secret.

Settings

Now that we've got reddit ready for us, we need to configure our program. Create an configuration file, either ion.toml in your working directory, or in ~/.config/ion/settings.toml. This file will contain your api access information as well as any other settings overwriting the defaults. Here's a sample.

[auth]
username = 'your-username'
password = 'your-password'

client-id = 'your-client-id'
client-secret = 'your-client-secret'
refresh-token = 'your-refresh-token'

If you don't have a refresh token yet, we'll set that up shortly, so don't worry about it. either leave it an empty string or just omit that line.

OAuth

Reddit knows about our scripts, our scripts know how to talk to reddit, but they don't actually have permission to do that just yet. Fortunately for you, there's a tool to make it easy, and you've already installed it. just run

ion_setup_oauth

It'll send you reddit asking for all the permissions we need, and start a little web server locally to collect what we need to get going. After you've accepted the request on reddit, you can go ahead and close out of the browser, we're done with it. The script should print out a line that looks something like

refresh-token = '56208746x-eC0VB-j2J4T9JoD91xNqclWmGk'

Copy that line and stick it in your configuration file. The scripts will use it, along with the other information we got from reddit earlier to prove that it has permission to operate on your behalf.

Rock-em Sock-em Robots

We're ready to roll. We've got everything we need installed, all the priveledges with reddit, and it looks like we're good to go. Let's take a moment here to pat ourselves on the back. We've done some good work.

Ok, I suppose we should get back to the real work here.

Network Preparation

If you're working on the ImagesOf network, skip this, it's already done.

Otherwise, this is for you. These scripts follow a model of one central subreddit forming a model for a bunch of other subreddits. We're going to create a network of subreddits, and each of those are going to copy settings from the master.

Go ahead and create your master subreddit. Set it up the way you want. Privacy settings, flairs, you name it, the basic settings, at least, will all be copied over when we start making the real subs in our network. Just not wiki pages. They're handled separately, mostly for moderation purposes.

Make sure you at least create the wiki pages 'userblacklist' and 'subredditblacklist'. You don't have to put anything in them if you don't want, but they need to be there. If you do want to blacklist some things off the bat, each should contain a list of users or subreddits, prefixed by /u/ or /r/, one per line.

Great, we've got something to work off of now. Let's move on.

Network Expansion

Adding new subreddits to the network should be a fairly simple process. We have A nice simple script to do the job for us. It assumes that our network name is a prefix, so if that's not what you want, you'll need to make some code adjustments. Otherwise, here's the command:

ion_expand Topic

Now watch it work it's magic. When it's done, you should have a nice, all prepared subreddit called NetworkNameTopic.

If you're nervous about automatically creating subreddits, you can take a look at what it's going to do by using the --dry-run flag. We won't hit reddit, but it should at least give you an idea of what's going to happen.

Now we probably want to do something with it. It's time to move back to our settings file. In settings.toml, you'll find a number of [child.subname] sections. Create a section for your new subreddit with all the configuration you need. There's a template to give you an idea of how things work.

Note: reddit only allows subreddit creation once every 10 minutes or so. Don't get too excited, take your time. Maybe use the time between creations to make sure everything looks right. If we didn't copy something right, let us know.

Running The Bot

We have credentials, we have a network, now let's start copying posts!

ion_bot

That's really all there is to it. Everything should be set up already. Maybe keep an eye on it amd make sure what it's doing is sane, but we should be in business.

Supervisord

Ok, ok, so nothing's perfect. We want to monitor our process so that if the bot fails, we can prop it back up again. supervisord is a sane choice. Make sure it's installed on your machine (excercise left up to the reader). Here's a little bit of configuration to get you started, assuming you went ahead and used the virtualenv as instructed.

[program:ion_bot]
directory=/path/to/ImagesOfNetwork/
command=/path/to/ImagesOfNetwork/venv-ion/bin/ion_bot
stdout_logfile=/var/log/ion_bot.stdout.log
stderr_logfile=/var/log/ion_bot.stderr.log

Replace /path/to with the appropriate path. Make sure supervisord is set up and running. You can then use supervisorctl to check on the status of the daemon, and see what we're logging in the specified logfile.

imagesofnetwork's People

Contributors

12thdoctor avatar 13steinj avatar amici-ursi avatar jazy510 avatar pygnus avatar sambol avatar scowcron avatar smithsoniandsp avatar whiskeyz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

imagesofnetwork's Issues

Make a welcome mat for Discord

Invites dump people into #general without any introduction. Instead, there should be a channel with a welcome message and information about the Discord server and project.

Unmoderated IoN Subs

I compiled a list of subreddits from the network that had no moderators other than the defaults.

I have reached out to all of the subreddits currently on this list and inviting the moderators of each subreddit to help with the subreddit related to their location. The form-letter templates used to contact the various subreddits have been moved here.

Now that all of them have been contacted, locations/places that we have found moderator(s) for will be checked off and formatted bold-strikethrough.

ย 

Unchecked items are subreddits without moderators (other than the defaults)

U.S. States

  • /r/ImagesOfArizona
  • /r/ImagesOfDelaware
  • /r/ImagesOfGeorgia
  • /r/ImagesOfHawaii
  • /r/ImagesOfIdaho
  • /r/ImagesOfIllinois
  • /r/ImagesOfIndiana
  • /r/ImagesOfKansas
  • /r/ImagesOfKentucky
  • /r/ImagesOfLouisiana
  • /r/ImagesOfMinnesota
  • /r/ImagesOfMississippi
  • /r/ImagesOfMontana
  • /r/ImagesOfMaine
  • /r/ImagesOfMaryland
  • /r/ImagesOfNebraska
  • /r/ImagesOfNevada
  • /r/ImagesOfNewHampshire
  • /r/ImagesOfNewJersey
  • /r/ImagesOfNorthCarolina
  • /r/ImagesOfNorthDakota
  • /r/ImagesOfOhio
  • /r/ImagesOfOklahoma
  • /r/ImagesOfOregon
  • /r/ImagesOfRhodeIsland
  • /r/ImagesOfSouthCarolina
  • /r/ImagesOfTennessee
  • /r/ImagesOfUtah
  • /r/ImagesOfVermont
  • /r/ImagesOfVirginia
  • /r/ImagesOfWestVirginia
  • /r/ImagesOfWyoming

Central & South America

  • /r/ImagesOfBelize
  • /r/ImagesOfBrazil
  • /r/ImagesOfGuatemala
  • /r/ImagesOfMexico
  • /r/ImagesOfPeru

Middle East & North Africa

  • /r/IMagesOfEgypt
  • /r/ImagesOfIran
  • /r/ImagesOfLibya
  • /r/ImagesOfSyria
  • /r/ImagesOfYemen

"Dahn Undah"

  • /r/ImagesOfAustralia
  • /r/ImagesOfNewZealand

Europe

  • /r/ImagesOfBelgium
  • /r/ImagesOfIsleOfMan
  • /r/ImagesOfNetherlands
  • /r/ImagesOfScotland
  • /r/ImagesOfWales

Add a license

I'm thinking an MIT license.

We need approval from all significant contributors.

  • amici-ursi
  • steinj
  • 12thDoctor
  • scowcron

If they want attribution, we should find out how they want it to show up in the license. If not, i think just an OK is fine. e.g. Real Name <[email protected]> or amici-ursi or however. I'd like to see comments below indicating acceptance and preferred attribution line info, if desired.

When that's done, we need to drop this into a LICENSE file (with appropriate copyright holders) at the root of the repo, and maybe set it up in the github repo settings, for metadata purposes.

Copyright (c) <year> <copyright holders>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

amici's baby

A certain subreddit needs some special treatment. For now, just make the bot do its searching and crossposting, but have none of the other scripts recognize it.

in the configuration, set up something like:

non-network=true

Click w/ config file

We're directly using click right now. We want to have everything that uses click to have a -c|--config=FILE option. extend or overwrite @click.command() to automatically add this option, use it instead of click's command().

we by default use {pwd}/ion.toml, ~/.config/ion/setttings.toml and the images_of/data/settings.toml in that order. read the --config file as most important.

Subreddit CSS

The network needs a unifying CSS style.

  • Prettier than the reddit default.
  • More focused on images. The reddit default is text focused.
  • Allows customizability for individual subreddits via header, background image, and colors.
  • Does not make the UX worse (Naut).

Put together network AutoModerator Anti-Spam rules

Need to put together some general anti-spam rules for AutoModerator that can go out to the entire network.

Would be nice if #29 could be done before the update goes out to prevent more issues with subreddit-specific rules getting overwritten.

Subreddit network management tools

Every mod action that gets done in one subreddit also needs to be propagable to the entire network of subreddits. Some of these actions are:

  • AutoModerator #29
  • subreddit/about/edit settings
  • subreddit/about/flair settings
  • sticky posts
  • sidebars
  • bans
  • mods
  • toolbox configs (/wiki/toolbox json) (amici has ideas for not breaking sub-specific settings)
  • CSS (including image uploads) #43
  • send modmail to each subreddit
  • about/rules #42

Where appropriate, we need to account for Network content and Subreddit content by using "start blah end" delimiters (for example, the sidebar and automoderator).

Let's use this issue to finalize the ideas we have on Discord.

hot_sister

use hot_sister to update child subreddits' sidebars with hot posts from the multi-reddit.

ion_propagate -f behavior non-apparent

the --force behavior is quirky and requires quite a bit of knowledge of the mechanics of the script to understand what it's going to do. I propose changing -f to --overwrite and if tags are missing, just completely overwrite the existing config.

edit:

the --force behavior is fairly close to what we really want to do, it just needs some documentation. we really need another option like --overwrite that explicitly copies what's in the master sub verbatim rather than doing anything intelligent. probably, --force and --overwrite should be mutually exclusive.

error reporting

We run the ion_blacklist script once a minute via cron, but it doesn't report if it fails. Same with the ion_bot script.

There should be some mechanism for reporting breakdowns to the developers.

Migrate the bot to a dedicated account

  • new username
  • new credentials
  • add bot as contributor to network subs
  • figure out how to get past the new-user rate limit. maybe ask admins for an api exception.
  • share the inbox to a private Discord channel via RSS
  • change OC announcer to account for new username
  • add reddit search RSS feed for posts mentioning the bot's username. Announce to Discord
  • update AutoModerator configs to account for new username
    - [ ] trackreddit.com for the new username

Reload Configuration

I'd be great to be able to send a HUP to the bot and have it reload it's configuration without killing the bot.

Need to add AutoMod rule to flair OC

The rule that should be added to AutoMod configs:

#Sets the flair for OC posted to the subreddit as the subreddit it was posted to
type: submission
author:
    ~name: ['amici_ursi', 'noeatnosleep']
set_flair: '[{{subreddit}}]'
overwrite_flair: true

Add direct image links

Check the URL for r"(\.jpg|\.jpeg|\.png|\.gif|\.gifv|\.apng|\.tiff|\.bmp|\.pdf|\.xcf)$"

Better user-requested blacklisting

When a user requests to be blacklisted, they send a modmail and we manually add that user to /r/imagesofnetwork/wiki/userblacklist. That is fine, but the process could be automated.

Clean up settings

the code that's in settings.py right now is ugly, and trying to overwrite the configuration doesn't always work exactly as you'd expect it to. logging.toml and loading logging configuration may also need some adjustment. Clean it up and document how the configuration files work.

error on running subreddit_setup_and_copy.py

Traceback (most recent call last):
  File "subreddit_setup_and_copy.py", line 102, in main
    ret = whipslaves(reddit_session, base_settings, do_mods, base_mods)
  File "subreddit_setup_and_copy.py", line 33, in whipslaves
    if add_to_multi:
UnboundLocalError: local variable 'add_to_multi' referenced before assignment

Improve blacklist_requests.py

  • Modify the script so that it only replies to users with confirmation that they have been added to the blacklist _after_ the blacklist has been successfully updated
  • If a user is already on the blacklist, send a reply to the user letting them (and the subreddit mods) know that they are already on the blacklist
  • Add exception catching?

Config file

Switch to a config file for credentials instead of importing from the OS.

Mark NSFW posts from whitelisted subreddits

The bot typically crossposts images before a user can mark them NSFW. In the unlikely event that,

  1. A whitelisted subreddit
  2. A NSFW post
  3. The bot currently skips the post. Instead it should mark the crosspost as NSFW

Remote management tool

in #58 amici suggests setting up some way for trusted users to update and manage the bot. I'm thinking a separate program acting as a manager with a simple api or some rpc capabilities aught to do the trick. We'd need to make sure it's all secured up, either way.

Stats

someday, long in the future, I'd like a bot to post a monthly summary of the network in the main sub. Subs started, subscribers gained, votes, etc.

@noeatnosleep

elaborate and be as specific as you can. all of your hopes and dreams for stats

Get a proper announcer for Discord

  • Announce non-trivial unread reddit messages to #mailbox
  • Announce false-positive reports to #false-positive
  • Announce github changes #dev
  • Announce OC content to #OC
  • Announce add/remove moderators (modlog actions) to #moderator

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.