예제 #1
0
파일: cli.py 프로젝트: wpappdev/Yatcobot
def main():
    parser = argparse.ArgumentParser(description='Yatcobot: a bot for entering twitter contests')
    parser.add_argument('--config', '-c', dest='config', default='config.yaml', help='Path of the config file')
    parser.add_argument('--ignore_list', '-i', dest='ignore_list', default='ignorelist', help='Path of the ignore file')
    parser.add_argument('--log', dest='logfile', default=None, help='Path of log file')
    parser.add_argument('--test-mail', action='store_true', dest='test_mail', default=False, help='Test mail settings')
    parser.add_argument('--debug', dest='debug', action='store_true', help='Enable debug')

    args = parser.parse_args()

    # Create logger
    if args.debug:
        create_logger(logging.DEBUG, args.logfile)
    else:
        create_logger(logging.INFO, args.logfile)

    # Check for old config
    if args.config.endswith('.json') or (os.path.isfile('config.json') and not os.path.isfile('config.yaml')):
        logger.error("Config file format changed, please update your config to the new yaml format!")
        logger.error("Visit documentation for more info: https://yatcobot.readthedocs.io/en/master/config.html")
        exit(1)

    logger.info("Loading configuration")
    TwitterConfig.load(args.config)
    logger.info("Configuration loaded")

    # Test mail settings and exit
    if args.test_mail:
        MailNotifier.from_config().test()
        exit(1)

    logger.info("Starting")
    print_logo()
    bot = Yatcobot(args.ignore_list)
    bot.run()
예제 #2
0
파일: cli.py 프로젝트: AkilesX/Yatcobot
def main():
    parser = argparse.ArgumentParser(description='Yatcobot: a bot for entering twitter contests')
    parser.add_argument('--login', dest='login', action='store_true', help='Login to twitter to get tokens')
    parser.add_argument('--config', '-c', dest='config', default='config.json', help='Path of the config file')
    parser.add_argument('--ignore_list', '-i', dest='ignore_list', default='ignorelist', help='Path of the ignore file')
    parser.add_argument('--log', dest='logfile', default=None, help='Path of log file')
    parser.add_argument('--debug', dest='debug', action='store_true', help='Enable debug')

    args = parser.parse_args()

    #Gets user tokens from twitter and saves them
    if args.login:
        tokens = get_access_token(Config.consumer_key, Config.consumer_secret)

        while True:
            user_input = input('Save tokens to {}? y/n '.format(args.config))
            user_input = user_input.lower()
            if user_input in ['y', 'n']:
                break
            else:
                print('That is not a valid option!')

        if user_input == 'y':
            Config.save_user_tokens(args.config, tokens['token'], tokens['secret'])

    #Create logger
    if args.debug:
        create_logger(logging.DEBUG, args.logfile)
    else:
        create_logger(logging.INFO, args.logfile)


    Config.load(args.config)

    bot = Yatcobot(args.ignore_list)
    bot.run()
예제 #3
0
파일: cli.py 프로젝트: bruvv/Yatcobot
    # Test mail settings and exit
    if args.test_mail:
        if notifier := [
                x for x in NotifierABC.get_enabled()
                if isinstance(x, MailNotifier)
        ]:
            notifier[0].test()
        else:
            logger.error(
                'Mail is not enabled, please enable it in the config and try again'
            )
        exit(1)

    logger.info(f"Starting Yatcobot ({__version__})")
    print_logo()
    bot = Yatcobot(args.ignore_list)
    bot.run()


def print_logo():
    # Figlet font: Standard
    logger.info('''                                                        
                                  .:clcllcll;.                                  
                                ;xc.        .ld'                                
                              .k:     .'..     xd                               
                              x;    cdcc:cx,    xc                              
                             .WolllxO 0oko.XolllxO                              
                              X,...;0.llo,,O....lO                              
                             l0x    .lllclc     0O;                             
                            OOkOk'            :OOdXl                            
                         .dkK;K' col,.    .;ld, oO:Xdo                          
예제 #4
0
 def setUp(self, config_mock, ignore_list_mock, client_mock):
     load_fixture_config()
     self.config = config_mock
     self.client = client_mock
     self.bot = Yatcobot('test')
예제 #5
0
 def setUp(self, config_mock, ignore_list_mock, client_mock):
     self.config = config_mock
     self.client = client_mock
     self.bot = Yatcobot('test')