Files
NijiHolo_EN_ID_Bot/src/main.py
T

53 lines
1.5 KiB
Python
Raw Normal View History

2022-09-10 00:47:47 -05:00
import sys
import argparse
from argparse import RawTextHelpFormatter
2022-09-10 01:21:19 -05:00
import secrets
import catchup
import listen
2022-09-10 00:47:47 -05:00
2022-09-12 01:31:09 -07:00
from api import API
import util
2022-09-12 01:31:09 -07:00
2022-09-10 00:47:47 -05:00
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\
2022-09-10 01:21:19 -05:00
l,listen: listen for new tweets from all accounts; will not terminate unless error occurs\n\
2022-09-10 00:47:47 -05:00
c,catchup: scan all tweets from all accounts; will terminate when done')
2022-09-10 01:21:19 -05:00
p.add_argument('--show-tokens', action='store_true', help='[DO NOT USE IN PUBLIC SETTING] print stored tokens from secrets.ini')
2022-09-10 00:47:47 -05:00
return p
2022-09-02 02:09:47 -07:00
def main():
2022-09-10 00:47:47 -05:00
parser = init_argparse()
if len(sys.argv) < 2:
parser.print_help()
return
args = parser.parse_args()
2022-09-10 01:21:19 -05:00
if args.show_tokens:
print(secrets.get_all_secrets())
if args.mode is None: return
util.twAPI = API()
resp = util.twAPI.get_user_tweets(1390620618001838086, count=5)
print(resp.data)
2022-09-12 01:31:09 -07:00
2022-09-10 01:21:19 -05:00
# determine running mode
match args.mode.lower():
2022-09-10 00:47:47 -05:00
case 'l' | 'listen':
2022-09-12 01:31:09 -07:00
print('RUNNING IN LISTEN MODE\n')
2022-09-10 01:21:19 -05:00
listen.run()
2022-09-12 01:31:09 -07:00
case 'c' | 'catchup':
print('RUNNING IN CATCH-UP MODE\n')
catchup.run()
2022-09-10 01:21:19 -05:00
case _:
print('\ninvalid mode. run with no arguments or "-h" for help page, including mode list.')
2022-09-10 01:21:19 -05:00
return
2022-09-10 00:47:47 -05:00
2022-09-02 02:09:47 -07:00
if __name__ == "__main__":
main()