예제 #1
0
def main():
    r = login()

    for msg in r.get_unread(unset_has_mail=True, update_user=True):
        if isinstance(msg, praw.objects.Message):
            # first check for bg3po commands.
            if msg.subject in cmds:
                if msg.author.name in cmds[msg.subject]['allowed']:
                    cmds[msg.subject]['cmd'](r, msg)

            else:   # All other messages the bg3po get the auto-response.
                msg.reply(AUTOREPLY_MSG)

            msg.mark_as_read()
예제 #2
0
def main():
    r = login()
    unread = r.inbox.unread(limit=None)

    for msg in unread:
        if isinstance(msg, Comment):
            # this is probably a mention in a comment body. Ignore it.
            pass
        elif isinstance(msg, Message):
            # first check for bg3po commands.
            if msg.subject in cmds:
                if msg.author.name in cmds[msg.subject]['allowed']:
                    log.info('Handling command {} from {}'.format(
                        msg.subject, msg.author.name))
                    cmds[msg.subject]['cmd'](r, msg)

            else:  # All other messages the bg3po get the auto-response.
                msg.reply(AUTOREPLY_MSG)

        log.info('Marking bg3po {} as read: {}'.format(msg.__class__, msg))
        msg.mark_read()
예제 #3
0
#!/usr/bin/env python

import praw
from argparse import ArgumentParser
from bg3po_oauth import login

if __name__ == "__main__":
    ap = ArgumentParser()
    ap.add_argument('-f', '--flair', help='Find users with the given flair')
    ap.add_argument('-s', '--subreddit', help='Search in given subreddit')
    args = ap.parse_args()

    r = login()
    sub = 'boardgames' if not args.subreddit else args.subreddit

    if args.flair:
        users = []
        for flair in r.subreddit(sub).flair_list(limit=None):
            if flair['flair_css_class'] == args.flair:
                users.append(flair['user'])

        users.sort()

        print('Users with {} flair:'.format(args.flair))
        for u in users:
            print('* /u/{}'.format(u))
예제 #4
0
        default='info',
        choices=[
            'none', 'all', 'debug', 'info', 'warning', 'error', 'critical'
        ])
    args = ap.parse_args()

    logLevels = {
        'none': 100,
        'all': 0,
        'debug': logging.DEBUG,
        'info': logging.INFO,
        'warning': logging.WARNING,
        'error': logging.ERROR,
        'critical': logging.CRITICAL
    }
    log_format = '%(asctime)s %(name)-12s %(levelname)-8s %(message)s'
    log_datefmt = '%m-%d %H:%M:%S'
    logging.basicConfig(format=log_format,
                        datefmt=log_datefmt,
                        level=logLevels[args.loglevel])

    reddit = login()

    # access to subreddit object
    subreddit = reddit.get_subreddit(args.subreddit)

    # generate_flair() will exit(1) on error.
    generate_flair(subreddit, args.imagedir)

    exit(0)
예제 #5
0
if __name__ == '__main__':
    '''A simple script that posts the game of the week for /r/boardgames'''
    ap = argparse.ArgumentParser()
    ap.add_argument(u'-w', u'--wiki', help=u'The wiki page from which to read/write the calendar info') 
    ap.add_argument(u'-s', u'--subreddit', help=u'The subreddit to update. Must have the gotw wiki '
                    u'page.')
    addLoggingArgs(ap)
    args = ap.parse_args()
    handleLoggingArgs(args)
    reddit_retry_timeout = 10 

    wiki_path = args.wiki if args.wiki else u'game_of_the_week'
    subreddit = args.subreddit if args.subreddit else u'boardgames'

    reddit = login()

    while True:
        try:
            gotw_wiki = reddit.get_wiki_page(subreddit, wiki_path)
            break
        except HTTPError:
            sleep(reddit_retry_timeout)

    log.debug(u'got wiki data: {}'.format(gotw_wiki.content_md))

    # finding the next GOTW is done in two parts. Find the wiki chunk, then find the list 
    # of games within that chunk
    search_for = u'\[//]:\s\(CALS\)\s+\s+\*\s+.*\[//]:\s\(CALE\)'
    match = re.search(search_for, gotw_wiki.content_md, flags=re.DOTALL)
    if not match:
예제 #6
0
def main():
    month = get_month()
    r = login()
    post_id = post_bazaar(r, month)
    change_sidebar(r, post_id, month)
예제 #7
0
def main():
    month = get_month()
    reddit = login()
    post_id = post_bazaar(reddit, month)
    change_sidebar(reddit, post_id, month)
예제 #8
0
#!/usr/bin/env python

import praw
from argparse import ArgumentParser
from bg3po_oauth import login


if __name__ == "__main__":

    ap = ArgumentParser()
    ap.add_argument('-f', '--flair', help='Find users with the given flair')
    ap.add_argument('-s', '--subreddit', help='Search in given subreddit')
    args = ap.parse_args()

    r = login()
    sub = 'boardgames' if not args.subreddit else args.subreddit

    if args.flair:
        users = []
        for flair in r.get_subreddit(sub).get_flair_list(limit=None):
            if flair['flair_css_class'] == args.flair:
                users.append(flair['user'])

        users.sort()

        print('Users with {} flair:'.format(args.flair))
        for u in users:
            print('* /u/{}'.format(u))