add toggle to enable/disable posting to pnut
This commit is contained in:
parent
f7e7cd60b8
commit
c7deb310b5
2 changed files with 22 additions and 3 deletions
23
feedbot.py
23
feedbot.py
|
@ -21,7 +21,7 @@ dr = False
|
|||
@click.option('--prime', is_flag=True)
|
||||
@click.option('--debug', is_flag=True)
|
||||
@click.option('--dryrun', is_flag=True)
|
||||
@click.version_option(version='0.1.1')
|
||||
@click.version_option(version='0.2.0')
|
||||
def main(ctx, db, prime, debug, dryrun):
|
||||
global dr
|
||||
|
||||
|
@ -61,6 +61,22 @@ def adduser(username, token):
|
|||
except pnutpy.errors.PnutAuthAPIException:
|
||||
logging.error(f"pnut user token not valid")
|
||||
|
||||
@main.command()
|
||||
@click.argument('uid')
|
||||
def enable(uid):
|
||||
'''Enable posts to pnut'''
|
||||
user = zdb.User.get(pnut_uid=uid)
|
||||
user.pnut_enabled = 1
|
||||
user.save()
|
||||
|
||||
@main.command()
|
||||
@click.argument('uid')
|
||||
def disable(uid):
|
||||
'''Disable posts to pnut'''
|
||||
user = zdb.User.get(pnut_uid=uid)
|
||||
user.pnut_enabled = 0
|
||||
user.save()
|
||||
|
||||
@main.command()
|
||||
@click.argument('uid')
|
||||
@click.argument('url')
|
||||
|
@ -95,10 +111,13 @@ def fetch(url, pnut_uid, fid, prime):
|
|||
if prime:
|
||||
logging.debug(f"saving {link}...")
|
||||
|
||||
else:
|
||||
elif user.pnut_enabled:
|
||||
logging.debug(f"posting {link}...")
|
||||
pnutpost(post, source, user.pnut_token)
|
||||
|
||||
else:
|
||||
logging.debug(f"pnut disabled, saving {link}...")
|
||||
|
||||
except zdb.User.DoesNotExist:
|
||||
logging.error(f"user {pnut_uid} not found")
|
||||
|
||||
|
|
2
setup.py
2
setup.py
|
@ -2,7 +2,7 @@ from setuptools import setup
|
|||
|
||||
setup(
|
||||
name='feedbot',
|
||||
version='0.1.1',
|
||||
version='0.2.0',
|
||||
py_modules=[
|
||||
'models',
|
||||
'feedbot',
|
||||
|
|
Loading…
Reference in a new issue