def run_praw_tasks():
    global logger
    from bot import RedditAgent
    cfg = configparser.ConfigParser()

    r = RedditAgent(ini_section='flairbot', user_agent='Flair helper by /u/gschizas version 0.2')

    search_space = json.loads(cfg.get('tasks', 'bitcoin_flair'))

    subreddits = {s[0] for s in search_space}

    offending_users = []
    sys.exit(99)
    for subreddit in subreddits:
        sr = r.get_subreddit(subreddit)
        flair_list = list(sr.get_flair_list(limit=None))
        flair_templates = sr.get_flair_choices()
        default_flair_text = {f['flair_css_class'][6:]: f['flair_text'] for f in flair_templates['choices']}
        extended_flair_list = [dict(
            f.items() | {'is_custom': default_flair_text.get(f['flair_css_class'], '***') != f['flair_text']}.items())
                               for f in flair_list]

        with open('flair_list-{}.json'.format(subreddit), mode='w', encoding='utf-8') as f:
            json.dump(extended_flair_list, f, ensure_ascii=False, sort_keys=True)

        for flair_item in flair_list:
            flair_text = flair_item.get('flair_text')
            if flair_text:
                bitcoin_addresses = re.findall('[13][a-km-zA-HJ-NP-Z0-9]{26,33}', flair_text)
                if len(bitcoin_addresses) > 0:
                    logging.warning(bitcoin_addresses)
                if any([check_bc(bc) for bc in bitcoin_addresses]):
                    offending_users.append([subreddit, flair_item['user']])
                if check_hyperlink(flair_text):
                    offending_users.append([subreddit, flair_item['user']])

    if len(offending_users) > 0:
        logging.warning(offending_users)
        existing_users = json.loads(cfg.get('tasks', 'bitcoin_flair'))
        full_users = offending_users + existing_users

        cfg.set('tasks', 'bitcoin_flair', json.dumps(list({(x[0], x[1]) for x in full_users})))

        cfg.write(sys.stdout)

        with open('flair-bot.ini', 'w') as f:
            cfg.write(f)

    r.clear_authentication()
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from bot import RedditAgent
import datetime

r = RedditAgent(ini_section='muteuserbot')
sr1 = r.get_subreddit('europe')

checked_users = []
muted_users = list(sr1.get_muted())
modmail = list(sr1.get_mod_mail(limit=20))

for message in modmail:
    author = message.author
    if author in checked_users:
        continue
    if author in muted_users:
        print('{} is already muted'.format(author))
        checked_users.append(author)
        continue
    created = datetime.datetime.fromtimestamp(author.created_utc)
    dt = datetime.datetime.utcnow() - created
    if dt.total_seconds() > 1 * 60 * 60: # half an hour seems enough
        print('{} is old enough ({})'.format(author, created.isoformat()))
        checked_users.append(author)
        continue
    print('Muting {} for message {}'.format(author, message.subject))
    message.mute_modmail_author()
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from bot import RedditAgent

# test
subreddits = ["gschizas"]
# prod
# subreddits = ['europe', 'greece']

# r = RedditAgent()
r = RedditAgent(ini_section="blackout", user_agent="French Blackout helper by /u/gschizas version 0.1")

href = "http://www.consilium.europa.eu/en/press/press-releases/2015/11/14-joint-eu-statement-terrorist-attacks-paris/"
stylesheet_addon = (
    '''.side a[href*="'''
    + href
    + """"] {
    position:fixed;
    top:0; left:0;
    height:100%;
    width:100%;
    z-index:9999;
    background:#000;
    color:#FFF;
    font-size:50px;
    line-height:500%;
    text-align:center;
}
body {
    overflow: hidden;
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from bot import RedditAgent
import ruamel.yaml as yaml

r = RedditAgent(ini_section="muteuser")
sr = r.get_subreddit("europe")
muted_users = list(sr.get_muted(user_only=False))
muted_usernames = [user["name"].name for user in muted_users]
permamutes = yaml.load(sr.get_wiki_page("permamuted").content_md)

for permamute in permamutes:
    print(permamute, permamute in muted_usernames)
    if permamute not in muted_usernames:
        sr.add_mute(permamute)