diff --git a/src/listen.py b/src/listen.py index 8c23122..e2b8dd3 100644 --- a/src/listen.py +++ b/src/listen.py @@ -1,2 +1,5 @@ ## The bot's listen mode -# Listen for cross-company interactions. \ No newline at end of file +# Continuously listen for cross-company interactions. + +def run(): + pass \ No newline at end of file diff --git a/src/main.py b/src/main.py index d4cc43d..3134eb8 100644 --- a/src/main.py +++ b/src/main.py @@ -1,23 +1,18 @@ import sys import argparse from argparse import RawTextHelpFormatter -import TwitterAPI as api -import catchup as catchup -HELP_TEXT = \ -'''OPTIONS: - -h Displays this help text. - -c, --catchup Scan all tweets from all accounts and makes posts all cross-company - interactions found. - -l, --listern Listen for all new tweets from all accounts. -''' +import secrets +import catchup +import listen def init_argparse(): p = argparse.ArgumentParser(description='Twitter bot that follows interactions between Nijisanji EN/ID and hololive EN/ID members.', formatter_class=RawTextHelpFormatter) p.add_argument('mode', nargs='?', \ help='mode to run the bot at:\n\ - l,listen: (default) listen for new tweets from all accounts; will not terminate unless error occurs\n\ + l,listen: listen for new tweets from all accounts; will not terminate unless error occurs\n\ c,catchup: scan all tweets from all accounts; will terminate when done') + p.add_argument('--show-tokens', action='store_true', help='[DO NOT USE IN PUBLIC SETTING] print stored tokens from secrets.ini') return p def main(): @@ -27,13 +22,23 @@ def main(): return args = parser.parse_args() - print(args.mode) - match args.mode: + if args.show_tokens: + print(secrets.get_all_secrets()) + + if args.mode is None: return + + # determine running mode + match args.mode.lower(): case 'l' | 'listen': - print('LISTEN MODE') + print('LISTEN MODE\n') + catchup.run() case 'c' | 'catchup': - print('CATCH-UP MODE') + print('CATCH-UP MODE\n') + listen.run() + case _: + print('\ninvalid mode. run with no arguments for help page, including mode list.') + return if __name__ == "__main__": diff --git a/src/secrets.py b/src/secrets.py index 8c7af91..2e49803 100644 --- a/src/secrets.py +++ b/src/secrets.py @@ -4,9 +4,9 @@ import os import configparser # returns dictionary of the Credentials section. -# NOT TO BE USED OUTSIDE OF THIS FILE. +# [NOT TO BE USED OUTSIDE OF THIS FILE.] def get_ini_credentials(): - c = configparser.ConfigParser() + c = configparser.RawConfigParser() if len(c.read(os.path.join(os.path.dirname(__file__), os.pardir, 'secrets.ini'))) > 0 and c.has_section('Credentials'): return c['Credentials'] return None @@ -24,7 +24,10 @@ def api_secret(): # returns the bearer_token stored in secrets.ini def bearer_token(): c = get_ini_credentials() - return c.get(option='bearer_token', fallback='xxx') if c is not None else 'zzz' + return c.get(option='bearer_token', fallback='zzz') if c is not None else 'zzz' + +def get_all_secrets(): + return f'api_key:{api_key()}\napi_secret:{api_secret()}\nbearer_token:{bearer_token()}' # print(api_key()) # print(api_secret())