WIP restructuring
This commit is contained in:
+2
-5
@@ -18,7 +18,7 @@ import talenttweet as tt
|
|||||||
import ttweetqueue as ttq
|
import ttweetqueue as ttq
|
||||||
|
|
||||||
PROGRAM_ARGS = None
|
PROGRAM_ARGS = None
|
||||||
safe_to_post_tweets = True
|
safe_to_post_tweets = False
|
||||||
errored = False
|
errored = False
|
||||||
|
|
||||||
## Returns the ID of all tweets (up to limit) from a user ID.
|
## Returns the ID of all tweets (up to limit) from a user ID.
|
||||||
@@ -133,13 +133,10 @@ async def process_queue() -> bool:
|
|||||||
|
|
||||||
# return True = no problems
|
# return True = no problems
|
||||||
# return False = issue occurred where we couldn't post all past tweets properly
|
# return False = issue occurred where we couldn't post all past tweets properly
|
||||||
async def run(program_args):
|
async def run():
|
||||||
global PROGRAM_ARGS
|
|
||||||
global errored
|
global errored
|
||||||
global safe_to_post_tweets
|
global safe_to_post_tweets
|
||||||
PROGRAM_ARGS = program_args
|
|
||||||
|
|
||||||
ret = None
|
|
||||||
queue = ttq.TalentTweetQueue.instance
|
queue = ttq.TalentTweetQueue.instance
|
||||||
while True:
|
while True:
|
||||||
await get_cross_talent_tweets()
|
await get_cross_talent_tweets()
|
||||||
|
|||||||
+9
-39
@@ -24,9 +24,6 @@ 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 = 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='?', \
|
p.add_argument('mode', nargs='?', \
|
||||||
help=MODES_HELP_STR)
|
help=MODES_HELP_STR)
|
||||||
p.add_argument('--show-tokens', action='store_true', help='[DO NOT USE IN PUBLIC SETTING] print stored tokens from secrets.ini')
|
|
||||||
p.add_argument('--announce-catchup', action='store_true', help='In catch-up mode, post a tweet announcing catch-up mode.')
|
|
||||||
p.add_argument('--auto-listen', action='store_true', help='In catch-up mode, transition to listen mode after successfuly catching up.')
|
|
||||||
p.add_argument('--no-delay', action='store_true', help='In self-destruct mode, clear tweets without safety waiting.')
|
p.add_argument('--no-delay', action='store_true', help='In self-destruct mode, clear tweets without safety waiting.')
|
||||||
return p
|
return p
|
||||||
|
|
||||||
@@ -45,56 +42,29 @@ async def self_destruct():
|
|||||||
async def async_main():
|
async def async_main():
|
||||||
global PROGRAM_ARGS
|
global PROGRAM_ARGS
|
||||||
|
|
||||||
## Determine running mode
|
if PROGRAM_ARGS.mode == None:
|
||||||
# match PROGRAM_ARGS.mode.lower():
|
await catchup.run()
|
||||||
# case 'l' | 'listen':
|
return
|
||||||
# print('RUNNING IN LISTEN MODE\n')
|
|
||||||
# await listen.run()
|
|
||||||
# case 'c' | 'catchup':
|
|
||||||
# print('RUNNING IN CATCH-UP MODE\n')
|
|
||||||
# if await catchup.run(PROGRAM_ARGS) and PROGRAM_ARGS.auto_listen:
|
|
||||||
# print('CATCH-UP MODE DONE, GOING INTO LISTEN MODE')
|
|
||||||
# await listen.run()
|
|
||||||
# case 'd' | 'delete-all':
|
|
||||||
# print('WARNING: SELF-DESTRUCT MODE')
|
|
||||||
# await self_destruct()
|
|
||||||
# case 'cmd':
|
|
||||||
# command_line()
|
|
||||||
# case _:
|
|
||||||
# print('\ninvalid mode. run with no arguments or "-h" for help page, including mode list.')
|
|
||||||
# return
|
|
||||||
mode = PROGRAM_ARGS.mode.lower()
|
mode = PROGRAM_ARGS.mode.lower()
|
||||||
if mode in ['l', 'listen']:
|
if mode in ['d', 'delete-all']:
|
||||||
print('RUNNING IN LISTEN MODE')
|
|
||||||
await listen.run()
|
|
||||||
elif mode in ['c', 'catchup']:
|
|
||||||
print('RUNNING IN CATCH UP MODE')
|
|
||||||
if await catchup.run(PROGRAM_ARGS) and PROGRAM_ARGS.auto_listen:
|
|
||||||
print('CATCH UP MODE DONE, GOING INTO LISTEN MODE')
|
|
||||||
listen.run()
|
|
||||||
elif mode in ['d', 'delete-all']:
|
|
||||||
print('WARNING: SELF-DESTRUCT MODE')
|
print('WARNING: SELF-DESTRUCT MODE')
|
||||||
await self_destruct()
|
await self_destruct()
|
||||||
elif mode == 'cmd':
|
elif mode == 'cmd':
|
||||||
command_line()
|
command_line()
|
||||||
else:
|
else:
|
||||||
print('\ninvalid mode. run with no arguments or -h for help and modes')
|
print('\nunknown mode. run with no arguments or -h for help and modes')
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
global PROGRAM_ARGS
|
global PROGRAM_ARGS
|
||||||
|
|
||||||
parser = init_argparse()
|
parser = init_argparse()
|
||||||
if len(sys.argv) < 2:
|
# if len(sys.argv) < 2:
|
||||||
parser.print_help()
|
# parser.print_help()
|
||||||
return
|
# return
|
||||||
|
|
||||||
PROGRAM_ARGS = parser.parse_args()
|
PROGRAM_ARGS = parser.parse_args()
|
||||||
|
|
||||||
if PROGRAM_ARGS.show_tokens:
|
|
||||||
print(api_secrets.get_all_secrets())
|
|
||||||
|
|
||||||
if PROGRAM_ARGS.mode is None: return
|
|
||||||
|
|
||||||
## We expect to run in some mode now.
|
## We expect to run in some mode now.
|
||||||
|
|
||||||
# Initialize shared API instance
|
# Initialize shared API instance
|
||||||
|
|||||||
+1
-1
@@ -18,7 +18,7 @@ def __create_dict(file, _dict, company):
|
|||||||
words = line.split()
|
words = line.split()
|
||||||
if len(words) == 2 and line[0] != '#':
|
if len(words) == 2 and line[0] != '#':
|
||||||
name, id = line.split()
|
name, id = line.split()
|
||||||
name = f'{util.get_username_online(id, default=name)}' # attempt to get updated name
|
# name = f'{util.get_username_online(id, default=name)}' # attempt to get updated name
|
||||||
talents[int(id)] = name
|
talents[int(id)] = name
|
||||||
_dict[int(id)] = name
|
_dict[int(id)] = name
|
||||||
talents_company[int(id)] = company
|
talents_company[int(id)] = company
|
||||||
|
|||||||
Reference in New Issue
Block a user