laying down the groundwork
This commit is contained in:
+4
-1
@@ -1,2 +1,5 @@
|
||||
## The bot's listen mode
|
||||
# Listen for cross-company interactions.
|
||||
# Continuously listen for cross-company interactions.
|
||||
|
||||
def run():
|
||||
pass
|
||||
+19
-14
@@ -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__":
|
||||
|
||||
+6
-3
@@ -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())
|
||||
|
||||
Reference in New Issue
Block a user