Python UserNotes Interface for reddit
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
ci
puni
tests
.coveragerc
.gitattributes
.gitignore
.travis.yml
LICENSE
README.md
setup.cfg
setup.py
test.py

README.md

PUNI

PyPI version Coverage Status Build Status Code Health

Python UserNotes Interface for Reddit.

Built to interact with the user notes data store from the reddit moderator toolbox (spec here).

Requirements:

  • PRAW
  • Python 2.7, or 3.X

Note: PUNI only supports usernotes of schema version 6.

Usage:

Full documentation.

Creating a usernotes object

import praw
import puni

r = praw.Reddit(...)
sub = r.subreddit('subreddit')
un = puni.UserNotes(r, sub)

Adding a note

# Create given note with time set to current time
link = 'http://www.reddit.com/message/messages/4vjx3v'
n = puni.Note('username', 'reason', 'moderator', link, 'permban')
un.add_note(n)

The list of warning types (like 'permban' as shown above), can be accessed from puni.Note.warnings.

Reading a user's notes

for note in un.get_notes('username'):
    print(note.note)

Pruning shadowbanned and deleted users

import puni
import praw

r = praw.Reddit(...)

sub = r.subreddit('my_subreddit')
un = puni.UserNotes(r, sub)

for user in un.get_users():
    try:
        u = r.redditor(user).fullname
    except:
        print("{} is shadowbanned/deleted".format(user))
        # To prevent unnecessary API requests, you need to specify remove_user
        # as lazy.
        un.remove_user(user, lazy=True)

# Now update the usernotes
un.set_json("Pruned users via puni")