This commit is contained in:
muskit
2024-01-26 22:15:13 -08:00
parent 9730f26cb6
commit 4878716460
+36 -12
View File
@@ -14,27 +14,49 @@ from twapi import TwAPI
PROGRAM_ARGS = None
MODES_HELP_STR = '''mode to run the bot at:
MODES_HELP_STR = """mode to run the bot at:
<blank> scrape accounts in lists and post cross-company tweets if relevant
cmd drop into Python interpretor with access to initialized variables'''
cmd drop into Python interpretor with access to initialized variables"""
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=MODES_HELP_STR)
p.add_argument('--no-listen', action='store_true', help='Run one scraping-posting cycle without waiting to run again.')
p.add_argument('--refresh-queue', action='store_true', help='Refresh the details on each tweet currently in queue.')
p.add_argument('--straight-to-queue', action='store_true', help='Go through queue first before attempting to pull tweets.')
p.add_argument('--post-id', action='append', help='ID of a tweet to try and post right away. Specify multiple to post multiple tweets in a row.')
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=MODES_HELP_STR)
p.add_argument(
"--no-listen",
action="store_true",
help="Run one scraping-posting cycle without waiting to run again.",
)
p.add_argument(
"--refresh-queue",
action="store_true",
help="Refresh the details on each tweet currently in queue.",
)
p.add_argument(
"--straight-to-queue",
action="store_true",
help="Go through queue first before attempting to pull tweets.",
)
p.add_argument(
"--post-id",
action="append",
help="ID of a tweet to try and post right away. Specify multiple to post multiple tweets in a row.",
)
return p
def command_line():
# TODO (extra): implement command line mode for manually controlling the bot
print('Here\'s a Python interpretor.')
print("Here's a Python interpreter.")
try:
code.interact(local=globals())
except SystemExit:
pass
async def async_main():
global PROGRAM_ARGS
@@ -46,10 +68,11 @@ async def async_main():
return
mode = PROGRAM_ARGS.mode.lower()
if mode == 'cmd':
if mode == "cmd":
command_line()
else:
print('\nunknown 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 init_data():
# Initialize shared API instance
@@ -60,12 +83,13 @@ def init_data():
if PROGRAM_ARGS.mode:
mode = PROGRAM_ARGS.mode.lower()
if mode != 'cmd':
if mode != "cmd":
# Initialize queue files system
ttq.TalentTweetQueue()
else:
ttq.TalentTweetQueue()
def main():
global PROGRAM_ARGS