From fbdce09230cd3a5cdc5cc0e4f3830372545a9091 Mon Sep 17 00:00:00 2001 From: Kay Faraday Date: Thu, 12 Jan 2023 00:19:04 +0000 Subject: [PATCH] =?UTF-8?q?elf=20=E2=86=92=20lef,=20remove=20oauth=20nonse?= =?UTF-8?q?nse?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 +- config.example.json | 4 ++++ lgfbot.py => ljfbot.py | 28 ++++++---------------------- requirements.txt | 2 ++ 4 files changed, 13 insertions(+), 23 deletions(-) create mode 100644 config.example.json rename lgfbot.py => ljfbot.py (96%) create mode 100644 requirements.txt diff --git a/.gitignore b/.gitignore index e4c1c93..d344ba6 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -.lgfbot +config.json diff --git a/config.example.json b/config.example.json new file mode 100644 index 0000000..a5d99b5 --- /dev/null +++ b/config.example.json @@ -0,0 +1,4 @@ +{ + access_token: "...", + site: "https://freak.university", +} diff --git a/lgfbot.py b/ljfbot.py similarity index 96% rename from lgfbot.py rename to ljfbot.py index c0b6e92..c8c084f 100755 --- a/lgfbot.py +++ b/ljfbot.py @@ -1,32 +1,16 @@ #!/usr/bin/env python import random -from getpass import getpass from mastodon import Mastodon import os +import json5 as json -if not os.path.exists('./.lgfbot/'): - os.mkdir('./.lgfbot') - -if not os.path.exists('./.lgfbot/lgf_client.secret'): - instance = input('Please enter your instance: ') - if instance[:4] != 'http': - instance = 'https://' + instance - Mastodon.create_app('Hourly lgf', api_base_url = instance, to_file = './.lgfbot/lgf_client.secret') +with open('config.json') as f: + config = json.load(f) mastodon = Mastodon( - client_id = './.lgfbot/lgf_client.secret', -) - -if not os.path.exists('./.lgfbot/lgf_user.secret'): - print('To post, lgfbot needs to generate an access token') - username = input('Enter your username: ') - password = getpass('Enter your password: ') - mastodon.log_in(username=username, password=password, scopes=['write:statuses'], to_file='./.lgfbot/lgf_user.secret') - - -mastodon = Mastodon( - access_token = './.lgfbot/lgf_user.secret' + access_token=config['access_token'], + api_base_url=config['site'], ) verbs = ['abide', 'accelerate', 'accept', 'accomplish', 'achieve', 'acquire', 'acted', 'activate', 'adapt', 'add', 'address', 'administer', 'admire', 'admit', 'adopt', 'advise', 'afford', 'agree', 'alert', 'alight', 'allow', 'altered', 'amuse', 'analyze', 'announce', 'annoy', 'answer', 'anticipate', 'apologize', 'appear', 'applaud', 'applied', 'appoint', 'appraise', 'appreciate', 'approve', 'arbitrate', 'argue', 'arise', 'arrange', 'arrest', 'arrive', 'ascertain', 'ask', 'assemble', 'assess', 'assist', 'assure', 'attach', 'attack', 'attain', 'attempt', 'attend', 'attract', 'audited', 'avoid', 'awake', 'back', 'bake', 'balance', 'ban', 'bang', 'bare', 'bat', 'bathe', 'battle', 'beam', 'bear', 'beat', 'beg', 'begin', 'behave', 'behold', 'belong', 'bend', 'beset', 'bet', 'bid', 'bind', 'bite', 'bleach', 'bleed', 'bless', 'blind', 'blink', 'blot', 'blow', 'blush', 'boast', 'boil', 'bolt', 'bomb', 'book', 'bore', 'borrow', 'bounce', 'bow', 'box', 'brake', 'branch', 'break', 'breathe', 'breed', 'brief', 'bring', 'broadcast', 'bruise', 'brush', 'bubble', 'budget', 'build', 'bump', 'burn', 'burst', 'bury', 'bust', 'buy', 'buze', 'calculate', 'call', 'camp', 'care', 'carry', 'carve', 'cast', 'catalog', 'catch', 'cause', 'challenge', 'change', 'charge', 'chart', 'chase', 'cheat', 'check', 'cheer', 'chew', 'choke', 'choose', 'chop', 'claim', 'clap', 'clarify', 'classify', 'clean', 'clear', 'cling', 'clip', 'close', 'clothe', 'coach', 'coil', 'collect', 'color', 'comb', 'come', 'command', 'communicate', 'compare', 'compete', 'compile', 'complain', 'complete', 'compose', 'compute', 'conceive', 'concentrate', 'conceptualize', 'concern', 'conclude', 'conduct', 'confess', 'confront', 'confuse', 'connect', 'conserve', 'consider', 'consist', 'consolidate', 'construct', 'consult', 'contain', 'continue', 'contract', 'control', 'convert', 'coordinate', 'copy', 'correct', 'correlate', 'cost', 'cough', 'counsel', 'count', 'cover', 'crack', 'crash', 'crawl', 'create', 'creep', 'critique', 'cross', 'crush', 'cry', 'cure', 'curl', 'curve', 'cut', 'cycle', 'dam', 'damage', 'dance', 'dare', 'deal', 'decay', 'deceive', 'decide', 'decorate', 'define', 'delay', 'delegate', 'delight', 'deliver', 'demonstrate', 'depend', 'describe', 'desert', 'deserve', 'design', 'destroy', 'detail', 'detect', 'determine', 'develop', 'devise', 'diagnose', 'dig', 'direct', 'disagree', 'disappear', 'disapprove', 'disarm', 'discover', 'dislike', 'dispense', 'display', 'disprove', 'dissect', 'distribute', 'dive', 'divert', 'divide', 'do', 'double', 'doubt', 'draft', 'drag', 'drain', 'dramatize', 'draw', 'dream', 'dress', 'drink', 'drip', 'drive', 'drop', 'drown', 'drum', 'dry', 'dust', 'dwell', 'earn', 'eat', 'edited', 'educate', 'eliminate', 'embarrass', 'employ', 'empty', 'enacted', 'encourage', 'end', 'endure', 'enforce', 'engineer', 'enhance', 'enjoy', 'enlist', 'ensure', 'enter', 'entertain', 'escape', 'establish', 'estimate', 'evaluate', 'examine', 'exceed', 'excite', 'excuse', 'execute', 'exercise', 'exhibit', 'exist', 'expand', 'expect', 'expedite', 'experiment', 'explain', 'explode', 'express', 'extend', 'extract', 'face', 'facilitate', 'fade', 'fail', 'fancy', 'fasten', 'fax', 'fear', 'feed', 'feel', 'fence', 'fetch', 'fight', 'file', 'fill', 'film', 'finalize', 'finance', 'find', 'fire', 'fit', 'fix', 'flap', 'flash', 'flee', 'fling', 'float', 'flood', 'flow', 'flower', 'fly', 'fold', 'follow', 'fool', 'forbid', 'force', 'forecast', 'forego', 'foresee', 'foretell', 'forget', 'forgive', 'form', 'formulate', 'forsake', 'frame', 'freeze', 'frighten', 'fry', 'gather', 'gaze', 'generate', 'get', 'give', 'glow', 'glue', 'go', 'govern', 'grab', 'graduate', 'grate', 'grease', 'greet', 'grin', 'grind', 'grip', 'groan', 'grow', 'guarantee', 'guard', 'guess', 'guide', 'hammer', 'hand', 'handle', 'handwrite', 'hang', 'happen', 'harass', 'harm', 'hate', 'haunt', 'head', 'heal', 'heap', 'hear', 'heat', 'help', 'hide', 'hit', 'hold', 'hook', 'hop', 'hope', 'hover', 'hug', 'hum', 'hunt', 'hurry', 'hurt', 'hypothesize', 'identify', 'ignore', 'illustrate', 'imagine', 'implement', 'impress', 'improve', 'improvise', 'include', 'increase', 'induce', 'influence', 'inform', 'initiate', 'inject', 'injure', 'inlay', 'innovate', 'input', 'inspect', 'inspire', 'install', 'institute', 'instruct', 'insure', 'integrate', 'intend', 'intensify', 'interest', 'interfere', 'interlay', 'interpret', 'interrupt', 'interview', 'introduce', 'invent', 'inventory', 'investigate', 'invite', 'irritate', 'itch', 'jail', 'jam', 'jog', 'join', 'joke', 'judge', 'juggle', 'jump', 'justify', 'keep', 'kept', 'kick', 'kill', 'kiss', 'kneel', 'knit', 'knock', 'knot', 'know', 'label', 'land', 'last', 'laugh', 'launch', 'lay', 'lead', 'lean', 'leap', 'learn', 'leave', 'lecture', 'led', 'lend', 'let', 'level', 'license', 'lick', 'lie', 'lifted', 'light', 'lighten', 'like', 'list', 'listen', 'live', 'load', 'locate', 'lock', 'log', 'long', 'look', 'lose', 'love', 'maintain', 'make', 'man', 'manage', 'manipulate', 'manufacture', 'map', 'march', 'mark', 'market', 'marry', 'match', 'mate', 'matter', 'mean', 'measure', 'meddle', 'mediate', 'meet', 'melt', 'melt', 'memorize', 'mend', 'mentor', 'milk', 'mine', 'mislead', 'miss', 'misspell', 'mistake', 'misunderstand', 'mix', 'moan', 'model', 'modify', 'monitor', 'moor', 'motivate', 'mourn', 'move', 'mow', 'muddle', 'mug', 'multiply', 'murder', 'nail', 'name', 'navigate', 'need', 'negotiate', 'nest', 'nod', 'nominate', 'normalize', 'note', 'notice', 'number', 'obey', 'object', 'observe', 'obtain', 'occur', 'offend', 'offer', 'officiate', 'open', 'operate', 'order', 'organize', 'oriented', 'originate', 'overcome', 'overdo', 'overdraw', 'overflow', 'overhear', 'overtake', 'overthrow', 'owe', 'own', 'pack', 'paddle', 'paint', 'park', 'part', 'participate', 'pass', 'paste', 'pat', 'pause', 'pay', 'peck', 'pedal', 'peel', 'peep', 'perceive', 'perfect', 'perform', 'permit', 'persuade', 'phone', 'photograph', 'pick', 'pilot', 'pinch', 'pine', 'pinpoint', 'pioneer', 'place', 'plan', 'plant', 'play', 'plead', 'please', 'plug', 'point', 'poke', 'polish', 'pop', 'possess', 'post', 'pour', 'practice', 'praised', 'pray', 'preach', 'precede', 'predict', 'prefer', 'prepare', 'prescribe', 'present', 'preserve', 'preset', 'preside', 'press', 'pretend', 'prevent', 'prick', 'print', 'process', 'procure', 'produce', 'profess', 'program', 'progress', 'project', 'promise', 'promote', 'proofread', 'propose', 'protect', 'prove', 'provide', 'publicize', 'pull', 'pump', 'punch', 'puncture', 'punish', 'purchase', 'push', 'put', 'qualify', 'question', 'queue', 'quit', 'race', 'radiate', 'rain', 'raise', 'rank', 'rate', 'reach', 'read', 'realign', 'realize', 'reason', 'receive', 'recognize', 'recommend', 'reconcile', 'record', 'recruit', 'reduce', 'refer', 'reflect', 'refuse', 'regret', 'regulate', 'rehabilitate', 'reign', 'reinforce', 'reject', 'rejoice', 'relate', 'relax', 'release', 'rely', 'remain', 'remember', 'remind', 'remove', 'render', 'reorganize', 'repair', 'repeat', 'replace', 'reply', 'report', 'represent', 'reproduce', 'request', 'rescue', 'research', 'resolve', 'respond', 'restored', 'restructure', 'retire', 'retrieve', 'return', 'review', 'revise', 'rhyme', 'rid', 'ride', 'ring', 'rinse', 'rise', 'risk', 'rob', 'rock', 'roll', 'rot', 'rub', 'ruin', 'rule', 'run', 'rush', 'sack', 'sail', 'satisfy', 'save', 'saw', 'say', 'scare', 'scatter', 'schedule', 'scold', 'scorch', 'scrape', 'scratch', 'scream', 'screw', 'scribble', 'scrub', 'seal', 'search', 'secure', 'see', 'seek', 'select', 'sell', 'send', 'sense', 'separate', 'serve', 'service', 'set', 'settle', 'sew', 'shade', 'shake', 'shape', 'share', 'shave', 'shear', 'shed', 'shelter', 'shine', 'shiver', 'shock', 'shoe', 'shoot', 'shop', 'show', 'shrink', 'shrug', 'shut', 'sigh', 'sign', 'signal', 'simplify', 'sin', 'sing', 'sink', 'sip', 'sit', 'sketch', 'ski', 'skip', 'slap', 'slay', 'sleep', 'slide', 'sling', 'slink', 'slip', 'slit', 'slow', 'smash', 'smell', 'smile', 'smite', 'smoke', 'snatch', 'sneak', 'sneeze', 'sniff', 'snore', 'snow', 'soak', 'solve', 'soothe', 'soothsay', 'sort', 'sound', 'sow', 'spare', 'spark', 'sparkle', 'speak', 'specify', 'speed', 'spell', 'spend', 'spill', 'spin', 'spit', 'split', 'spoil', 'spot', 'spray', 'spread', 'spring', 'sprout', 'squash', 'squeak', 'squeal', 'squeeze', 'stain', 'stamp', 'stand', 'stare', 'start', 'stay', 'steal', 'steer', 'step', 'stick', 'stimulate', 'sting', 'stink', 'stir', 'stitch', 'stop', 'store', 'strap', 'streamline', 'strengthen', 'stretch', 'stride', 'strike', 'string', 'strip', 'strive', 'stroke', 'structure', 'study', 'stuff', 'sublet', 'subtract', 'succeed', 'suck', 'suffer', 'suggest', 'suit', 'summarize', 'supervise', 'supply', 'support', 'suppose', 'surprise', 'surround', 'suspect', 'suspend', 'swear', 'sweat', 'sweep', 'swell', 'swim', 'swing', 'switch', 'symbolize', 'synthesize', 'systemize', 'tabulate', 'take', 'talk', 'tame', 'tap', 'target', 'taste', 'teach', 'tear', 'tease', 'telephone', 'tell', 'tempt', 'terrify', 'test', 'thank', 'thaw', 'think', 'thrive', 'throw', 'thrust', 'tick', 'tickle', 'tie', 'time', 'tip', 'tire', 'touch', 'tour', 'tow', 'trace', 'trade', 'train', 'transcribe', 'transfer', 'transform', 'translate', 'transport', 'trap', 'travel', 'tread', 'treat', 'tremble', 'trick', 'trip', 'trot', 'trouble', 'troubleshoot', 'trust', 'try', 'tug', 'tumble', 'turn', 'tutor', 'twist', 'type', 'undergo', 'understand', 'undertake', 'undress', 'unfasten', 'unify', 'unite', 'unlock', 'unpack', 'untidy', 'update', 'upgrade', 'uphold', 'upset', 'use', 'utilize', 'vanish', 'verbalize', 'verify', 'vex', 'visit', 'wail', 'wait', 'wake', 'walk', 'wander', 'want', 'warm', 'warn', 'wash', 'waste', 'watch', 'water', 'wave', 'wear', 'weave', 'wed', 'weep', 'weigh', 'welcome', 'wend', 'wet', 'whine', 'whip', 'whirl', 'whisper', 'whistle', 'win', 'wind', 'wink', 'wipe', 'wish', 'withdraw', 'withhold', 'withstand', 'wobble', 'wonder', 'work', 'worry', 'wrap', 'wreck', 'wrestle', 'wriggle', 'wring', 'write', 'x-ray', 'yawn', 'yell', 'zip', 'zoom'] @@ -36,7 +20,7 @@ postform = random.choice(( '{adjective} {gender}', '{gender} who {verb}', )) -gender = random.choice(('lgf', 'lbf', 'elf')) +gender = random.choice(('lgf', 'lbf', 'lef')) verb = random.choice(verbs) if verb[-2:] == 'ed' and verb[-3] not in {'a', 'e', 'i', 'o', 'u'}: verb = verb[:-2] diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..ebf52d9 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +mastodon.py ~= 1.8 +json5 ~= 0.9.11