コード例 #1
0
ファイル: fbcide.py プロジェクト: compfaculty/fbcide
def start_blocking(login, passw, scums_file):
    fb = init(login, passw)
    # records = scums()
    for i, line in enumerate(scums_file):
        if scum_exists(line): continue  # if url in file already in DB - continue
        # if line in records: continue  # if url in file already in DB - continue
        try:
            with timeout(30):
                fb.block(line)
                # sleep(t)
        except (Exception,) as e:
            logger.error("cycle error {}".format(e))
            system("killall firefox")
            fb = init(login, passw)
            sleep(t)
        else:
            logger.info("{0}:{1} is blocked".format(str(i), line))
コード例 #2
0
ファイル: fbcide.py プロジェクト: compfaculty/fbcide
    # we need subparsers for check mode and block mode
    subparsers = parser.add_subparsers(dest='subparser_name', help='blocking or cheking mode')

    # check mode subparser
    check_parser = subparsers.add_parser('check', help='check mode -- check if url is in DB')
    check_parser.add_argument("url", type=str)
    check_parser.set_defaults(func=_get_check_args)

    # block mode subparser
    block_parser = subparsers.add_parser('block', help='block mode')
    block_parser.add_argument("login", help="facebook login", type=str)
    block_parser.add_argument("password", help="facebook password", type=str)
    block_parser.add_argument("filename", help="input file with list of bots accounts", metavar="file",
                              type=lambda x: _is_valid_file(parser, x))
    block_parser.set_defaults(func=_get_block_args)

    return parser.parse_args()
    # id_list, mode, count = args.ids, args.mode, args.count


if __name__ == "__main__":
    args = parse_cmd()
    if args.subparser_name == 'check':
        if scum_exists(args.url):
            print("Account {0:>} is already blocked".format(args.url))
        else:
            print("Account {0:>} is not in database".format(args.url))
    else:
        # print((args.login, args.password, args.filename))
        start_blocking(args.login, args.password, args.filename)